[R] Beginer data.frame

K. Elo maillists at nic.fi
Tue Jan 12 12:42:08 CET 2010


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



More information about the R-help mailing list