Mutating multiple columns in a data frame using dplyr

后端 未结 4 2040
一个人的身影
一个人的身影 2020-12-09 05:24

I have the following data frame df:

  v1 v2 v3 v4
1  1  5  7  4
2  2  6 10  3

And I want to obtain the following data frame

4条回答
  •  心在旅途
    2020-12-09 06:00

    Just use mutate as is with a comma to separate new columns mutate(df,"v1v3"=v1*v3,"v2v4"= v2*v4)

提交回复
热议问题