Hi! Jean-Baptiste Combes wrote: > Hello, > > I use R 2.10, and I am new in R (I used to use SAS and lately Stata), I am > using XP. > > I have a data which has a data.frame format called x.df (read from a csv > file). I want to take from this data observations for which the variable > "Code" starts with an "R". I took all the Code and put them into a vector > vec<-grep("R[A-Z][A-Z]",x.df$Code,value=TRUE)
I am not sure if I understood you correctly, but could a simple: subset(x.df, substring(Code,1,1)=="R") be an appropriate solution? HTH, Kimmo ______________________________________________ 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.