stan-dev/posterior

[FR?] rvar works in data.frame but not data.table

Open

#234 opened on Apr 5, 2022

View on GitHub
 (8 comments) (0 reactions) (0 assignees)R (24 forks)github user discovery
help wanted

Repository metrics

Stars
 (171 stars)
PR merge metrics
 (PR metrics pending)

Description

Not sure if this is a posterior issue or data.table issue but it looks like you cannot put rvars into data.table but it does work with data.frame

library(data.table)
library(posterior)
n <- 4   # length of output vector
x_rvar <- rvar(array(rnorm(4000*n, mean = 1, sd = 1), dim = c(4000, n)))
x_rvar
# rvar<4000>[4] mean ± sd:
#   [1] 0.98 ± 1.00  1.00 ± 1.02  1.00 ± 0.99  0.99 ± 0.99 
# does not work :(
ex_dt = data.table(ex = x_rvar)
ex_dt
# Empty data.table (0 rows and 1 cols): ex
# does work
ex_df = data.frame(ex = x_rvar)
ex_df
# ex
# 1 0.9778591 ± 1.0010389
# 2 1.0015836 ± 1.0206705
# 3 0.9964342 ± 0.9948071
# 4 0.9947569 ± 0.9921549

Contributor guide