[R] Splitting dataframes and cleaning extraneous characters

arun smartpink111 at yahoo.com
Wed Jul 17 17:06:09 CEST 2013


Hi,
YOu could try.
?split()
split(ats,ats$Project_NBR)
You also mentioned about two columns.

split(ats,list(ats$col1, ats$col2))

You should have provided an example dataset using ?dput() ( dput(head(data,10)) ) for testing.
Also,

gsub("^-[^-]*-","","-005-190")
#[1] "190"
A.K.




Problem: I have a large data set and need to separate based on factors 
in 2 columns. The final output would be a collection of dataframes 
renamed to 

the corresponding factor levels.   

So far I know that for each corresponding factor I can execute 

x190<-ats[which(Project_NBR=='-005-190'),] 

However there are about 400 factors needing to be separated. 
Also, I would like to remove the "-005-".  Any guidance will be greatly 
appreciated.  



More information about the R-help mailing list