![](/img/trans.png)
[英]How to write an R if statement that selects between 2 data columns and returns one based on the value of a third column
[英]Using IF statement to compare values of two columns, how to swap value in one column for other based on statement
你可以用data.table
library(data.table)
setDT(combined_data)
combined_data[PM_base > PM_RAMP, PM_base := PM_RAMP]
如果可行,請嘗試並提供反饋。
PS:下次請提供一些數據。 最好使用dput()
,因此更容易重現和測試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.