Let's say I have a set of CSV files in a folder called "my data" which is a folder in my working directory. The CSV files are matrices and looking something like:
> a
[,1] [,2] [,3] [,4]
[1,] 3 3 3 3
[2,] 3 3 3 3
[3,] 3 3 3 3
[4,] 3 3 3 3
> b
[,1] [,2] [,3] [,4]
[1,] 1 1 1 1
[2,] 2 2 2 2
[3,] 1 1 1 1
[4,] 2 2 2 2
> c
[,1] [,2] [,3] [,4]
[1,] 3 3 3 3
[2,] 9 9 9 9
[3,] 3 3 3 3
[4,] 9 9 9 9
Let's say I have another folder in my working directory called "my results." In it I want to create another CSV file (call it "my_results") that has the results of the analyses performed on the CSV files in "my data." For example if I calculated the mean and standard deviation of a, b, and c "my_results" would look like:
> my_results
mean sd
a 3.0 0.00
b 1.5 0.52
c 6.0 3.10
The idea being every row of the new CSV would correspond to one of the CSVs in "my data" and the columns of the new CSV would correspond to a particular analysis run. Thank you.
setwd("mydata"); out <- do.call("rbind", lapply(dir(), function(x) dosomething(data = read.csv(x)))); write.csv(out, file = "../myresults/my_results.csv"); setwd("..")- Thomas