Something really odd is going on here. In the code below, I create a variable called temp
. I have to call it twice before I can see what it is. E.g. The first time I call it, the console shows nothing. The second time it shows the data.table
/data.frame
that it is. Can anyone help me understand what's going on here?
library(magrittr)
library(data.table)
myDT <- as.data.table(mtcars)
temp <-
myDT %>%
melt(id.vars = c('cyl', 'mpg', 'hp'),
measure.vars = c('vs','am','gear','carb'),
variable.name = 'Data') %>%
extract( value > 0) %>%
extract( , value := NULL)
What my console is doing (the first call doesn't do anything):
> temp
> temp
cyl mpg hp Data
1: 4 22.8 93 vs
2: 6 21.4 110 vs
3: 6 18.1 105 vs
4: 4 24.4 62 vs
5: 4 22.8 95 vs
...
...