js.huang at protective.com
2015-Feb-17 04:41 UTC
[R] split dataframe to several dataframes in R
<quote author='R help mailing list-2'> Hi All,I have a dataframe called 'means' as shown below:iris1.csv <- iris iris2.csv <- iris names <- c("iris1.csv", "iris2.csv") dat <- mget(names) lst4 <- lapply(dat, function(x) apply(x[,-5], 2, mean)) # Build the new data frame means <- as.data.frame(do.call(rbind, lst4)) means$source <- names(lst4) means # Sepal.Length Sepal.Width Petal.Length Petal.Width isv source # iris1.csv 5.843333 3.057333 3.758 1.199333 0.3333333 iris1.csv # iris2.csv 5.843333 3.057333 3.758 1.199333 0.3333333 iris2.csvQUESTION: How can I split 'means' such that there are two files (dataframes) on my workspace:datframe 1# Sepal.Length Sepal.Width Petal.Length Petal.Width isv # iris1.csv 5.843333 3.057333 3.758 1.199333 0.3333333dataframe 2:# Sepal.Length Sepal.Width Petal.Length Petal.Width isv# iris2.csv 5.843333 3.057333 3.758 1.199333 0.3333333 Many thanks,Asong. [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. </quote> Quoted from: http://r.789695.n4.nabble.com/split-dataframe-to-several-dataframes-in-R-tp4703372.html _____________________________________ Sent from http://r.789695.n4.nabble.com