You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can use e.g. na.omit to mirror the data.table behavior like .I[na.omit(A > 1)] but doing the reverse seems awkward:
idx = DT[is.na(A) | A > 1, which = TRUE]
is.na(idx) <- is.na(DT[idx]$A)
idx
# [1] NA 2 3 6
I thought this in ?data.table might be helpful:
which
TRUE returns the row numbers of x that i matches to. If NA, returns the row numbers of i that have no match in x. By default FALSE and the rows in x that match are returned.
Sort of reads like DT[A > 1, which = NA] should return 1L, but it errors instead:
DT[A > 1, which = NA]
Error in if (which) return(if (is.null(irows)) seq_len(nrow(x)) else irows) :
missing value where TRUE/FALSE needed
Should we change the documentation, or is this a bug?
The text was updated successfully, but these errors were encountered:
Was answering this question:
https://stackoverflow.com/q/61554066/3576984
and trying to mirror
base
behavior withwhich
, i.e., forwhich
to returnNA
elements ofi
asNA
:whereas
We can use e.g.
na.omit
to mirror thedata.table
behavior like.I[na.omit(A > 1)]
but doing the reverse seems awkward:I thought this in
?data.table
might be helpful:Sort of reads like
DT[A > 1, which = NA]
should return1L
, but it errors instead:Should we change the documentation, or is this a bug?
The text was updated successfully, but these errors were encountered: