stan-dev/posterior

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

Aperta

#234 aperta il 5 apr 2022

 (8 commenti) (0 reazioni) (0 assegnatari)R (26 fork)github user discovery
help wanted

Metriche repository

Star
 (171 stelle)
Metriche merge PR
 (Merge medio 8g 3h) (1 PR mergiata in 30 g)

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