[R] subset

2011-06-23 Thread yf
Dear all, How can I do the subset fucntion from the table? I want to do the subset for the less than 50. I tried b8a<-subset(b8, (table(g$book)<50)==TRUE) but it didn't work. Thanks. table(g$ book ) 119 121 134 160 161 170 175 179 190 193 225 226 256 260 130 89 50 8774 23 8547

[R] split the data

2011-02-23 Thread yf
x<-data.frame(id=c(1,1,2,2,3,3,4,4), v1=c(1:8), V2=c(9:16)) > x id v1 V2 1 1 1 9 2 1 2 10 3 2 3 11 4 2 4 12 5 3 5 13 6 3 6 14 7 4 7 15 8 4 8 16 1) I want to split the data into 2 group with one unique ID. I should use the split function but i don't know how to write it out. 2

[R] convert the sas file into csv in R

2011-02-17 Thread yf
i am trying to convert sas file into csv. I used write.csv(a, file="cool.csv") but nothing come out. i don't know why. Thanks. library(Hmisc) a<- sasxport.get("C:\\Users\.") write.csv(a, file="cool.csv") -- View this message in context: http://r.789695.n4.nabble.com/convert-the-sas-file-in

Re: [R] sampling

2011-02-17 Thread yf
But i need for each id have two data. Like... > x id v1 V2 1 1 1 12 2 1 2 13 4 2 4 15 5 2 5 16 8 3 8 19 9 3 9 20 11 4 11 22 12 4 12 23 So should write sample( if sample id >2 ,2). I don't know how to write (if sample id >2). Thanks. -- View this message in context:

[R] sampling

2011-02-17 Thread yf
I want to sample from the ID. For each ID, i want to have 2 set of data. I try the sample() function but it didn't work. > x<-data.frame(id=c(1,1,1,2,2,2,2,3,3,3,4,4), v1=c(1:12), V2=c(12:23)) > x id v1 V2 1 1 1 12 2 1 2 13 3 1 3 14 4 2 4 15 5 2 5 16 6 2 6 17 7 2 7 18 8