Dear All, I am using the example from one of the tutorial about "Metafor" package and "escalc" function, to learn how this package can be applied to do meta-analysi; the code and the data is directly from the tutorials but "weights=freq" option in the escalc function is given me error message This is the code below:
library(metafor) # Load package #####DATASET 1: BCG Vaccine Trials data(dat.bcg) # BCG meta-analytic dataset ##Formula based Specification ##That is, what if I have multiple rows per study, corresponding to difference treatment groups? library(reshape2) # Load package for data reshaping bcg.long <- melt(dat.bcg[, c("trial", "tpos", "tneg", "cpos", "cneg")], id = "trial") bcg.long$pos <- ifelse(bcg.long$var == "tpos" | bcg.long$var == "cpos", 1, 0) bcg.long$group <- ifelse(bcg.long$var == "tpos" | bcg.long$var == "tneg", 1, 0) ##sample of the data, the first 6 rows head(bcg.long) trial variable value pos group 1 1 tpos 4 1 1 2 2 tpos 6 1 1 3 3 tpos 3 1 1 4 4 tpos 62 1 1 5 5 tpos 33 1 1 6 6 tpos 180 1 1 ##Now applying the " escalc " function escalc(factor(pos)~factor(group)| factor(trial),weights = value,data = bcg.long, measure = "OR") ##Then I got this error message Error in escalc(factor(pos) ~ factor(group) | factor(trial), weights = value, : object 'value' not found I used the same data with different example from another author and got a similar error message Second code with the same data but different coding Sample data with the first 6 rows of the rearranged data shown below. (T=treatment, C=Control group, Out=outcome whether positive or negative, and then frequency) study grp out freq 1 1 T + 4 2 1 T - 119 3 1 C + 11 4 1 C - 128 5 2 T + 6 6 2 T - 300 >escalc(out ~ grp | study, weights = freq, data = dat.fm, measure = "OR") Error in escalc(out ~ grp | study, weights = freq, data = dat.fm, measure = "OR") : object 'freq' not found I am not sure what I am doing wrong since both authors were able to get their results while I am getting error messages. Any help will be very much appreciated Amoatwi [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.