Re: [R] Regular expressions & sub

From: bogdan romocea <br44114_at_gmail.com>
Date: Fri 19 Aug 2005 - 02:36:05 EST


One solution is
test <- c("1.11","10.11","11.11","113.31","114.2","114.3") id <- unlist(lapply(strsplit(test,"[.]"),function(x) {x[2]}))

> -----Original Message-----
> From: Bernd Weiss [mailto:bernd.weiss@uni-koeln.de]
> Sent: Thursday, August 18, 2005 12:10 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Regular expressions & sub
>
>
> Dear all,
>
> I am struggling with the use of regular expression. I got
>
> > as.character(test$sample.id)
> [1] "1.11" "10.11" "11.11" "113.31" "114.2" "114.3" "114.8"
>
> and need
>
> [1] "11" "11" "11" "31" "2" "3" "8"
>
> I.e. remove everything before the "." .
>
> TIA,
>
> Bernd
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Aug 19 02:43:51 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:30:55 EST