I'm using the metacor function from the meta package with RStudio 1.4.1103 to test a meta-analytic bivariate correlation between self-reported 'propensity to trust' and 'trust in one's teammates', yet encounter an issue with my dataframe. I've imported the data from SPSS with this syntax:
library(foreign)
df=read.spss("Model 1.sav", use.value.labels=F, to.data.frame=T)
Here are the key components of the dataframe for this query:
studyid <- c('study1','study2','study3','study4','study5','study6','study7','study8','study9','study10','study11','study12','study13')
n <- c(87.0,30.0,8.0,79.0,68.0,62.0,16.0,26.0,28.0,19.0,96.0,27.0,34.0)
correlation <- c(.110,.380,.610,.170,.190,.350,.510,.190,.620,.790,.310,.840,.200)
df <- data.frame(studyid,n,correlation)
When I run the main model...
library(meta)
model1 <- metacor(cor = correlation,
n = n,
studlab = studyid,
data = df,
comb.fixed = FALSE,
comb.random = TRUE,
sm = "ZCOR",
method.tau = "ML")
summary(model1)
...I receive this error "$ operator is invalid for atomic vectors". I've checked the dataframe is not atomic:
is.atomix(df)
[1] FALSE
I can access specific elements of the dataframe, such as the correlations, but am unable to execute the meta-analytic component:
df$correlation
[1] 0.11 0.38 0.61 0.17 0.19 0.35 0.51 0.19 0.62 0.79 0.31 0.84 0.20
Does anyone know solutions to resolve this error with metacor?