lapply and mutate_all/for loops

后端 未结 1 1059
天涯浪人
天涯浪人 2021-01-27 10:09

I have several data frames within a list which I have to modify by normalizing all the data, in all columns (basically, divide each row/column by the sum of the number of that c

相关标签:
1条回答
  • 2021-01-27 11:06

    You can just use your described function and adapt for the function argument. In dplyr, the . stands, in this case, for the variable. The ~ defines a formula.

    samples <- lapply(names(samplelist), function(processing){
      aux <- read.csv(samplelist[[processing]], header = T, sep = "") %>% 
        mutate_all(~./sum(.))
    })
    
    0 讨论(0)
提交回复
热议问题