r - Want to find the column difference in the list of dataframe -


i want find rmse between columns in each dataframe present in list. have written below code:

i3<-2:6 for(iter in 1:length(filenames)){ # length(filename)=45   (i in seq_along(i3)){     rmse<-lapply(filelist, function(x) sqrt(mean(as.numeric(x[[iter]][[7]])-as.numeric(x[[iter]][[i]]))^2))   } } 

but code not working fine.

dataframes in below format:

df1:     col2 col3 col4 col5 col6 col7      5     4    3     2     3  4          4     2    3    4      4  2        df2:     col2 col3 col4 col5 col6 col7       5     4    3     2     3  4          4     2    3    4      4  2    

i want o/p in below form:

df1: col2 col3 col4 col5 col6 col7 rmse(7-2) rmse(7-3) rmse(7-4) rmse(7-5)  5     4    3     2     3  4     4.5        3.5     4.3        2.4 4     2    3    4      4  2      3.5       2        3.5        2.4  df2: col2 col3 col4 col5 col6 col7 rmse(7-2) rmse(7-3) rmse(7-4) rmse(7-5)  5     4    3     2     3  4     4.5        3.5     4.3        2.4 4     2    3    4      4  2      3.5       2        3.5        2.4 

thanks in advance!!

you might want in purrr:map() or map2()

here i've refactored code bit... still isn't going work, might bit closer want.

rmse <- list()  for(i in 1:length(filenames)) {     df <- read.file(filenames[i])     for(j in 2:6) {         rmse[i] <- lapply(df, fun)     } } 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -