Remove elements in a vector that are greater than value

后端 未结 1 1054
挽巷
挽巷 2021-01-15 04:36

I need to remove elements (that I am plotting with error bars, so I need to remove that data point from all four vectors below) where the diff vector is greater

相关标签:
1条回答
  • 2021-01-15 04:54

    Don't use a for loop. Do something like this if you want to replace certain values by NA:

    Z[diff >= 2*std] = NA
    

    Alternatively, if you want to just filter out the rows that don't satisfy the condition, subset only the rows you want:

    Z <- Z[diff < 2*std]
    
    0 讨论(0)
提交回复
热议问题