I need to take 3rd column for each one of 50 csv files that I have and get variances of them in R.
files <- list.files(path="path\\to\\csv", pattern="*.csv", full.names=T, recursive=FALSE)
lapply(files, function(x) {
t <- read.csv(x, header=F) # load file
# apply function
out <- var(t[3])
out
# write to file
#write.csv(out, "path\\to\\dir\\variances.csv", sep="\t", quote=F, row.names=F, col.names=T)
})
This is what I have so far, and I need some help on how I can use from 2nd row to the last row for each csv files to get variances and only 3rd columns.
Also, if I can write a dataframe with each file's name without ".csv" as column names and their variances as values in a csv file. Basically it will be a 1x50 data frame
Thank you for your help