Multiplying all columns in dataframe by single column

前端 未结 5 626
情书的邮戳
情书的邮戳 2020-12-21 02:10

I know it is a basic quaestion but couldnt find any solution to it. I want to multiply all columns of a dataframe by single column.

df1<-data.frame(F1=c(1         


        
5条回答
  •  情深已故
    2020-12-21 02:34

    The overkill dplyr solution

    library(dplyr)
    
    df1 %>%
      mutate_all(.,function(col){C$C*col})
    

提交回复
热议问题