I'm using R and have a problem in a data.table
Both of these commands return NA
for all rows:
AfAm[, sizediffpos := max(0,sizediff)]
AfAm[, sizediffpos := max(0,sizediff, na.rm = TRUE)]
Is there any way I can rectify the error?
I'm using R and have a problem in a data.table
Both of these commands return NA
for all rows:
AfAm[, sizediffpos := max(0,sizediff)]
AfAm[, sizediffpos := max(0,sizediff, na.rm = TRUE)]
Is there any way I can rectify the error?
As rawr points out, the correct way is to use pmax
:
AfAm[, sizediffpos := pmax(0,sizediff)]