Normalizing selection of dataframe columns with dplyr

后端 未结 2 1547
说谎
说谎 2021-01-21 22:31

I have a data.frame with variables var1 var2 (both strings) and variables x, y, and z. I would like

2条回答
  •  星月不相逢
    2021-01-21 23:10

    Building on @akrun's answer, you can also use the first() function from dplyr:

    df_ %>%
            mutate_at(vars(c("x", "y", "z")), funs(norm = ./first(.)))
    

提交回复
热议问题