有人可以帮我解决这个问题,需要创建函数来使列总和加倍

Can someone help me to solve this, need to create function to double the column sum

我缺少 1 行来显示第 3 列,有人可以帮忙吗。

 df_dummy = data.frame(ID = c(1001:1010), 
                      INT1 = sample(x = c(1:200), size = 10, replace = T)
)

col_double = function(df, col){
   df[,'double'] = df[,col]*2
}

col_double(df = df_dummy, col = 'INT1')

在函数中定义 return 对象 df:

col_double = function(df, col){
  df[,'double'] <- df[,col]*2
  df
}
    ID INT1 double
1  1001  168    336
2  1002  154    308
3  1003  198    396
4  1004   89    178
5  1005  197    394
6  1006    4      8
7  1007   53    106
8  1008  108    216
9  1009  138    276
10 1010   75    150