Modify values in a column subject to condition?

后端 未结 2 899
小鲜肉
小鲜肉 2021-01-21 12:21

I know that this is a very silly question but I cannot work out how to do it. I want to subtract 300 from the values on each row on the trial1 column if they are larger than 29

相关标签:
2条回答
  • 2021-01-21 13:03

    Why not just use mod(x,300) ? [charcountfiller]


    0 讨论(0)
  • 2021-01-21 13:04

    Your first attempt was close but there is no -= operator in base R, so you need to supply the subset on the right hand side as well.

    sums[sums$trial1 > 299,"trial1"] <- sums[sums$trial1 > 299,"trial1"]-300
    
    0 讨论(0)
提交回复
热议问题