0

I am meta analyzing everything related to listening (e.g., listening and leadership, listening and job satisfaction, etc.). I would like to have all the effects in a single file and run separate meta analyses based on topic. [I have some 70 topics].

I am a newcomer to R, and thought that the tapply function could work, but could not figure out how to use it.

To test the idea I tried to create a command that will run a separate meta-analysis for the variable r"moderator". First, I successfully ran metacor with the variable as a moderator:

metacor(rho,N,Study,data=Leadership,comb.fixed=F,prediction=T,byvar=Leadership$Moderator)

Then, I tested successfully the logic of tapply:

tapply(Leadership$rho,Leadership$Moderator,mean)

Now, I wanted to replace the mean function with metacor and tried unsuccessfully to write

tapply(,Leadership$Moderator,metacor(rho,N,Study,data=Leadership,comb.fixed=F,prediction=T))

I would greatly appreciate any advice.

Avi

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
Avi Kluger
  • 91
  • 6
  • You left the first argument to `tapply` blank by starting with a comma. The code should look like `tapply(Leadership$Moderator, function(args) ... do stuff ... )` – Frank Feb 13 '15 at 20:52
  • Removing the blank created – Avi Kluger Feb 14 '15 at 08:48
  • tapply(Leadership$Moderator,metacor(rho,N,Study,data=Leadership,comb.fixed=F,prediction=T)) Error in tapply(Leadership$Moderator, metacor(rho, N, Study, data = Leadership, : arguments must have same length In addition: Warning messages: 1: In ngroup * (as.integer(index) - one) : NAs produced by integer overflow 2: In ngroup * nlevels(index) : NAs produced by integer overflow – Avi Kluger Feb 14 '15 at 08:48

2 Answers2

0

In

tapply(X, INDEX, FUN = NULL, ..., simplify = TRUE)

replace ... with optional arguments to FUN

tapply(Leadership$rho,Leadership$Moderator,metacor,n=N,studlab=Study,data=Leadership,comb.fixed=F,prediction=T)
xb.
  • 1,617
  • 11
  • 16
0

The following code solve the problem -- I thank both commentators

    dlply(Leadership, .(Moderator), function(Leadership) metacor(rho,N,Study,data=Leadership,comb.fixed=F,prediction=T))
Avi Kluger
  • 91
  • 6