esc library and data frame creating in R

Hello R community!

I'm making a data frame based on the Suicideprevention dataset in "dmetar", when i run this code :

SP_calc <- esc_mean_sd(grp1m = SuicidePrevention$mean.e,grp1sd = SuicidePrevention$sd.e, grp1n = SuicidePrevention$n.e,grp2m = SuicidePrevention$mean.c,grp2sd = SuicidePrevention$sd.c,grp2n = SuicidePrevention$n.c,study = SuicidePrevention$author,es.type = "g") %>% as.data.frame()

I get this error:

Error in missing(grp1sd) || is.null(grp1sd) || is.na(grp1sd) :
'length = 9' in coercion to 'logical(1)'

nothing is missed in this dataset; can anyone help me with this error?
thanks in advance <3

Should be

SuicidePrevention$n.c,grp2m

oh, unfortunately the error is still there, btw I'm defining two groups, the first one's being 'e' and second one is 'c', that's the reason it's coded like this.

1 Like

(Facepalm)

I see that in the help(esc_mean_sd) examples all the arguments are given as single integers and when those are replaced with vectors the same error is given.

library(esc)
# with standard deviations for each group
esc_mean_sd(
  grp1m = 7, grp1sd = 2, grp1n = 50,
  grp2m = 9, grp2sd = 3, grp2n = 60,
  es.type = "g"
)
#> 
#> Effect Size Calculation for Meta Analysis
#> 
#>      Conversion: mean and sd to effect size Hedges' g
#>     Effect Size:  -0.7655
#>  Standard Error:   0.1984
#>        Variance:   0.0394
#>        Lower CI:  -1.1544
#>        Upper CI:  -0.3766
#>          Weight:  25.4015

v <- 1:10

esc_mean_sd(
  grp1m = v, grp1sd = v, grp1n = v,
  grp2m = v, grp2sd = v, grp2n = v,
  es.type = "g"
)
#> Error in missing(grp1sd) || is.null(grp1sd) || is.na(grp1sd): 'length = 10' in coercion to 'logical(1)'

Created on 2023-11-25 with reprex v2.0.2

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.