Is there a way to subset a data table using "i" with multiple criteria using
multiple variables(columns)? I have some test code shown below on what I
have tried. And yes, I have read the documentation, taking the data camp
class (Multiple viewing, I'm a slow learner) and have not seen anything
necessary in `i`. You can also
chain data.tables:
dt[a<35][b>35][, lapply(.SD, median, na.rm = T), by = d]
--Mel.
On 12/9/2015 1:02 PM, carlsutton wrote:
> Is there a way to subset a data table using "i" with multiple criteria using
> multiple variables(columns)? I hav
Please forgive me for asking such a basic question. I have been fumbling
around trying to learn R for a couple years via Data Camp, Coursera, and
Lynda.com but keep amazing myself at how inadequate I am.
I have searched this site and stack overflow and have not found an answer,
probably because
Hi
I did search but did not see an answer.
I have a dt with 580 + columns. many of the columns will have variations of
a name to specifically identify them, ie, call23,Call111, doCall.now, etc.
Since I cannot recall the exact column names I have been resorting todf
<- data.frame(dt) and
Thank you, I did not even think of wrapping in ( ) for the ':=" scenario.
Feeling a bit silly about that.
Just fooling around I did discover that dt[, "new.var" := fun(var), by =
something] does work.
For some reason I had been wrapping that (go figure), i.e. dt[, .("new.var"
:= fun(var)), by
I can do the calculation on a couple columns, but how do I automate this for
192 column data table?
# calculating proportion for column variables
library(data.table)
a <- rep(1:5, 2)
b <- sample(20:50, size = 10, replace = TRUE)
c <- sample(80:130, size = 10, replace = TRUE)
dt1 <-
As a result of some computations using data.table wherein the computations
require using "i" to select certain rows, the results of the computations
only reside in those certain rows. Further computations require that the
computation results be in each row by group. A much simplified example
Hi
Thanks to the help from this list I was able to get the toy data to work and
subsequently got cast to work. With anticipation of wonderful things to
happen with real data, I copied the command from toy data to melt real data
and R complained.
What I would like to know:
1. What is wrong