1
Der Versuch, Zeilen zu verwerfen, wo V1 größer als 1 ist OR V3 größer als 0,5Filter data.table Reihen mit zwei numerische Spalten
library(data.table)
set.seed(45L)
DT <- data.table(V1=c(1L,2L),
V2=LETTERS[1:3],
V3=round(rnorm(4),4),
V4=1:12)
# tried this approach to get the rows
DT[ .(V1<1,V3<0.5) ]
Error in bmerge(i, x, leftcols, rightcols, io, xo, roll, rollends, nomatch, :
x.'V2' is a character column being joined to i.'V2' which is type logical'.
# found this solution, but it's a very dirty one. Looking for cleaner approach.
# and being afraid of duplicate rows that meet the two conditions
rbind(DT[ V1<1 ],DT[ V3<0.5 ])
Just do 'DT [V1> 1 | V3> 0.5] 'Hier ist der OR-Teil' | ' – akrun
Ich habe bemerkt, dass du den Beitrag editiert hast. Also wäre es "DT [V1 <1 | V3 <0.5] ' – akrun
so, einfach und so peinlich – useRj