Hi, I'm trying to create a function to return three dataframes for later use in a graphic so I want the return from the function to give me dataframes and with unique names relating to the variable they are based on. For example.....
sub<-c("6-1a","6-1a","6-1a","9-2b","9-2b","9-2b","7c","7c","7c") yar<-rep(1991:1993,3) x1n<-c(4,6,3,6,4,7,9,4,2) y1m<-c(3,7,5,8,4,3,6,7,8) prac<-data.frame(sub,yar,x1n,y1m) plot.restrut<-function(org.plot,ex.plot) { new.pl<-org.plot[org.plot$sub %in% ex.plot,] new.pl.st<-new.pl[new.pl$yar %in% "1991",] new.pl.fin<-new.pl[new.pl$yar %in% "1993",] print(new.pl) print(new.pl.st) print(new.pl.fin) } plot.restrut(prac,"9-2b") ###### I would like the output to be one dataframe with the name "9.2b.new" which is new.pl in the example Another data frame to be "9.2bnew1991" and another dataframe "9.2bnew1993" I want the dataframe names to relate to the variables they have come from because I want to use the same function to extract lots of subsets of my data. Thanks Chris -- View this message in context: http://r.789695.n4.nabble.com/dataframes-from-a-function-tp3260581p3260581.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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.