Using lapply to create new columns based on old columns

后端 未结 3 1890
攒了一身酷
攒了一身酷 2021-01-28 19:14

My data looks as follows:

DF <- structure(list(No_Adjusted_Gross_Income = c(183454, 241199, 249506
), NoR_from_1_to_5000 = c(1035373, 4272260, 1124098), NoR_f         


        
3条回答
  •  执念已碎
    2021-01-28 19:55

    you can use apply to get your values, then use cbind if you want to combine with your original DF

    t(apply(DF[,2:3],1, function(x) x*val ))
    
     NoR_from_1_to_5000 NoR_from_5000_to_10000
    [1,]         2588950187             2396550000
    [2,]        10682786130            36195315000
    [3,]         2810807049            14698995000
    

提交回复
热议问题