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
Disclaimer: this is basically me doing a mistake, but because it may raise a more general question -- if an argument value not described in the help text should result in an error -- I thought I just as well could share it.
My intention was to achieve the functionality of . (". represents no variable") in the dcast formula. But, I had forgot the correct syntax and just throwed in a 1 instead (I might have thought of the 'no variable' / intercept only in lm...).
The 1 in the formula gave the desired (dot-)result, but when I saw the . in the variable name I realized my mistake. Should it be possible to use argument values not described in the help text?
# some data
d <- data.table(x = rep(LETTERS[1:2], each = 4),
y = rep(letters[1:2], each = 2),
z = 1:8)
# correct dot code, which I had forgot
dcast(d, x + y ~ ., value.var = "z", fun.aggregate = sum)
# my erroneous code, with a 1 instead of a dot gives the same result
dcast(d, x + y ~ 1, value.var = "z", fun.aggregate = sum)
# x y .
# 1: A a 3
# 2: A b 7
# 3: B a 11
# 4: B b 15
# just to try what may translate to a dot - anything..;)
dcast(d, x + y ~ "anything", value.var = "z", fun.aggregate = sum)
# x y .
# 1: A a 3
# 2: A b 7
# 3: B a 11
# 4: B b 15
The text was updated successfully, but these errors were encountered:
Disclaimer: this is basically me doing a mistake, but because it may raise a more general question -- if an argument value not described in the help text should result in an error -- I thought I just as well could share it.
My intention was to achieve the functionality of
.
(".
represents no variable") in thedcast
formula. But, I had forgot the correct syntax and just throwed in a1
instead (I might have thought of the 'no variable' / intercept only inlm
...).The
1
in the formula gave the desired (dot-)result, but when I saw the.
in the variable name I realized my mistake. Should it be possible to use argument values not described in the help text?The text was updated successfully, but these errors were encountered: