loops - How to find mean of values over multiple csv files in R -
i trying write r function can loop through 300 .csv files , calculate mean of columns. can give me high level guidance on how this? files in same directory , have same column headings. mechanics of shouldn't hard, having hard time finding plenty documentation on r syntax this. please help. give thanks you.
there few ways load files r, easiest using list.files function. code this:
setwd("") # set directory files <- list.files() #load file names workspace for(i in sequence(length(files))){ yourdata <- read.scv(files[i]) yourmeans <- apply(yourdata, 1, mean) #save means in meaningful way each csv. }
r loops csv directory mean
No comments:
Post a Comment