Q:

R using max function in data table

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?

A:

As rawr points out, the correct way is to use pmax:
AfAm[, sizediffpos := pmax(0,sizediff)]

