Reputation: 2065
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?
Upvotes: 1
Views: 3183
Reputation: 2065
As rawr points out, the correct way is to use pmax
:
AfAm[, sizediffpos := pmax(0,sizediff)]
Upvotes: 4