wviechtb/metafor

rcalc function

carolaruizh opened this issue · 3 comments

Classification:

Bug Report

Summary

The rcalc function works with the dataset from the example dat.craft2003 but does not work with other datasets.

Reproducible Example (if applicable)

When running the example provided with the package from the dat.craft2003 it runs well and then it can be used by he rma.mv function.
Example from the package:
tmp <- rcalc(ri ~ var1 + var2 | study, ni=ni, data=dat)
V <- tmp$V
dat <- tmp$dat

However, when using other datasets and reproducing the same process, at the moment of doing the last step, (dat<-tmp$dat) this returns dat as empty. The previous two steps seem to work well.

I tried it with different datasets and even with one that resembled exactly the Craft2003 one from a csv file and the same problem occurred.

I understand that this might be a consequence of the function being under development and I apologise if that is the case.

Best regards,

Please provide a reproducible example. Here is one that works using a different dataset:

library(metafor)

mydat <- data.frame(
   id  = c(1,1,1,2,2,3),
   x   = c(1,1,2,1,1,2),
   y   = c(2,3,3,2,3,3),
   cor = rep(.30, 6),
   N   = rep(40, 6))

rcalc(cor ~ x + y | id, ni=N, data=mydat)

tmp does not contain an element called mydat. Look at (i.e., print) tmp to see what it contains.