Re: [R] cutting out numbers from vectors

From: Hans-Jörg Bibiko <bibiko_at_eva.mpg.de>
Date: Sat, 21 Jun 2008 11:47:28 +0200

On 20.06.2008, at 19:27, calundergrad wrote:

>
> i have a vector with a string of number
> e.g
>
> [1] 01130010000 001130011000 001130012000 001130013000 001130016000
> [6] 001130018000
>
> i want a vector with the same numbers except with the last three
> digits of
> every factor cut off.
> e.g
>
> [1] 01130010 001130011 001130012 001130013 001130016
> [6] 001130018
>
> how do i accomplish this?

One way:

gsub("(.*)(.{3})", "\\1", YOUR_VECTOR)

--Hans



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 21 Jun 2008 - 09:50:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 21 Jun 2008 - 11:30:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive