I have a list of 30 dataframes.
I want to create a vector that contains the standard deviation of the nth element of one of the columns, across all 30 data frames in the list of dataframes. I don't think I've explained that clearly. But the code for my for loop should make it clear.
FFT233_sd <- list()
for (i in 1:431999) {FFT233_sd[[i]] <- sd(c(FFT233_data[[1]][i,6], FFT233_data[[2]][i,6], FFT233_data[[3]][i,6], FFT233_data[[4]][i,6], FFT233_data[[5]][i,6], FFT233_data[[6]][i,6], FFT233_data[[7]][i,6], FFT233_data[[8]][i,6], FFT233_data[[9]][i,6], FFT233_data[[10]][i,6], FFT233_data[[11]][i,6], FFT233_data[[12]][i,6], FFT233_data[[13]][i,6], FFT233_data[[14]][i,6], FFT233_data[[15]][i,6], FFT233_data[[16]][i,6], FFT233_data[[17]][i,6], FFT233_data[[18]][i,6], FFT233_data[[19]][i,6], FFT233_data[[20]][i,6], FFT233_data[[21]][i,6], FFT233_data[[22]][i,6], FFT233_data[[23]][i,6], FFT233_data[[24]][i,6], FFT233_data[[25]][i,6], FFT233_data[[26]][i,6], FFT233_data[[27]][i,6], FFT233_data[[28]][i,6], FFT233_data[[29]][i,6], FFT233_data[[30]][i,6]))}
That for loop works, but is obviously quite slow. I have been told I should use lapply, but i do not understand how to do that. I have tried the following:
results2738 <- lapply( FFT2738_data , function(x) {sd(x) } )
but it has resulted in teh following errror:
Show Traceback
Rerun with Debug
Error in is.data.frame(x) :
(list) object cannot be coerced to type 'double' In addition: Warning message:
In mean.default(x) : argument is not numeric or logical: returning NA
If anyone can suggest a resource for me to investigate, i would be greatful.