Try:
s1 <- "hello.world"
s2 <- c("GLEm0045", "GLEn0042", "GLEz0048")

 substr(s1,1,5)
#or
gsub("\\..*","",s1)

n <- 5
substr(s2,nchar(s2)-n +1,nchar(s2))


A.K.



If I have a column that has "hello.world"  how   could I extract hello? 
 In addition in a column how can I extract the last 5 characters?    For 
example from character  G1Em0017  I wish to extract m0017 .

______________________________________________
R-help@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.

Reply via email to