stan-dev/posterior

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

Open

#234 aperta il 5 apr 2022

Vedi su GitHub
 (8 commenti) (0 reazioni) (0 assegnatari)R (24 fork)github user discovery
help wanted

Metriche repository

Star
 (171 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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

Guida contributor