Re: [R] Divide the data into sub data on a particular condition

2013-08-25 Thread raishilpa
thank you so much :) On Sun, Aug 25, 2013 at 7:48 AM, arun kirshna [via R] < ml-node+s789695n4674466...@n4.nabble.com> wrote: > > > Hi, > Try this: > > sapply(lst1,function(x) with(x,cor(CF,OSA))) > # 2231 2232 2233 > #-0.9607689 -1.000 0.9973233 > #or > library(plyr) > dd

Re: [R] Divide the data into sub data on a particular condition

2013-08-24 Thread arun
Hi, Try this: sapply(lst1,function(x) with(x,cor(CF,OSA))) #  2231   2232   2233 #-0.9607689 -1.000  0.9973233 #or library(plyr)  ddply(dat1,.(BaseProd),summarize,Cor=cor(CF,OSA)) #  BaseProd    Cor #1 2231 -0.9607689 #2 2232 -1.000 #3 2233  0.9973233 #or  

Re: [R] Divide the data into sub data on a particular condition

2013-08-24 Thread arun
Hi, Use ?split() #dat1 is the dataset: lst1<- split(dat1,dat1$BaseProd) lst1 #$`2231`  # BaseProd  CF OSA #1 2231 0.5 0.7 #2 2231 0.8 0.6 #3 2231 0.4 0.8 # #$`2232`  # BaseProd CF OSA #4 2232  1   2 #5 2232  3   1 # #$`2233`  # BaseProd  CF OSA #6 2233 0.9 0.5 #7 2233 0.