I have a very dataset which I want to put in new dataframes according to date. Example: Suppose I have number day month hours 1 1 14 10 2 2 2 14 10 12 3 3 14 10 18 4 4 15 10 3 5 5 15 10 14 6 6 16 10 18 7 7 16 10 20 8 8 16 10 23 9 9 20 10 1 10 10 21 10 14 11 11 21 10 15 Now I want to get 5 new data frames, with first one number day month hours 1 1 14 10 2 2 2 14 10 12 3 3 14 10 18 etc. Is there an efficient way to do this? Thanks for the help -- View this message in context: http://r.789695.n4.nabble.com/putting-data-frame-values-in-new-dataframes-tp4655474.html Sent from the R help mailing list archive at Nabble.com.
thank you very much, I have a smaller question: If I give the first dataframe a name, say data1. How can I read it without pasting the dataframe -- View this message in context: http://r.789695.n4.nabble.com/putting-data-frame-values-in-new-dataframes-tp4655474p4655482.html Sent from the R help mailing list archive at Nabble.com.
Perhaps split(mydf, paste(mydf$month,mydf$day)) -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 1/14/13 5:57 AM, "condor" <radonnikodym at hotmail.nl> wrote:>I have a very dataset which I want to put in new dataframes according to >date. Example: >Suppose I have > > number day month hours >1 1 14 10 2 >2 2 14 10 12 >3 3 14 10 18 >4 4 15 10 3 >5 5 15 10 14 >6 6 16 10 18 >7 7 16 10 20 >8 8 16 10 23 >9 9 20 10 1 >10 10 21 10 14 >11 11 21 10 15 > >Now I want to get 5 new data frames, with first one > number day month hours >1 1 14 10 2 >2 2 14 10 12 >3 3 14 10 18 > >etc. > >Is there an efficient way to do this? Thanks for the help > > > >-- >View this message in context: >http://r.789695.n4.nabble.com/putting-data-frame-values-in-new-dataframes- >tp4655474.html >Sent from the R help mailing list archive at Nabble.com. > >______________________________________________ >R-help at 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.
Hi, Do you want to read it from a saved file? res<-split(dat1,dat1$day) ?res[[1]] names(res)<-paste("data",1:5,sep="") ?write.table(res[[1]],file="data1.txt") ?read.table("data1.txt",sep="",header=TRUE) #? number day month hours #1????? 1? 14??? 10???? 2 #2????? 2? 14??? 10??? 12 #3????? 3? 14??? 10??? 18 A.K. ----- Original Message ----- From: condor <radonnikodym at hotmail.nl> To: r-help at r-project.org Cc: Sent: Monday, January 14, 2013 9:55 AM Subject: Re: [R] putting data.frame values in new dataframes thank you very much, I have a smaller question: If I give the first dataframe a name, say data1. How can I read it without pasting the dataframe -- View this message in context: http://r.789695.n4.nabble.com/putting-data-frame-values-in-new-dataframes-tp4655474p4655482.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.