Is it possible to combine the chain and destination by reference in the data table.
For example, I would like to do this:
DT[a == 1][b == 0, c := 2]
However, this leaves the original table unchanged, since a temporary table is created after DT [a == 1], which subsequently changes and returns.
I would rather not do
DT[a == 1 & b == 0, c := 2]
as it is very slow and i would also prefer to avoid
DT <- DT[a == 1][b == 0, c := 2]
since I would rather do the job by reference. This question is part of the question [1], where it remains unanswered.
[1] Conditional binary connection and update by reference using the data.table package
, , DT[a == 1][b == 0, c := 2] , , DT[a == 1 & b == 0, c := 2]
a b
a
b
DT <- data.table(a = c(1, 1, 1, 2, 2), b = c(0, 2, 0, 1, 1)) ## mock data setkey(DT, a, b) ## keying by both `a` and `b` DT[J(1, 0), c := 2] ## Update `c` by reference DT # a b c # 1: 1 0 2 # 2: 1 0 2 # 3: 1 2 NA # 4: 2 1 NA # 5: 2 1 NA
Source: https://habr.com/ru/post/1584132/More articles:Deploying a standalone OCaml native application - linuxRails 4.2 rendering JSON formatting DateTime weirdly - ruby-on-railsCould not find "ng" in module ... - Broken Intellisense? - javascriptDebugging three-dimensional mouse coordinates raycaster - canvashttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1584131/is-there-a-one-liner-for-submiting-many-jobs-to-slurm-similar-to-lsf&usg=ALkJrhjsHJifCQjJd_IPXQsOytJRuFd1xAStrange NHibernate QueryOver syntax error - mysqlOrientDB shortestPath () using a specific @class edge? - javaRepresentation of a set in java and CQL - javaThe rfsrc () command in the randomForestSRC R package that does not use multicore functionality - parallel-processingcheck if the same value exists in the input field - jqueryAll Articles