0

I tried to generate all sd of a list of list but it shows this error:

Error in rapply(d, sd, how = "list") : invalid 'f' argument

My code:

d3 <-rapply(d, sd, how = 'list')

d is a list and is there any way to generate all sd of list?

d <-list()
for (i in 1:19){

  d[[i]] <- rnorm(30,mean = 25,sd= 8)
}

BTW,

d2 <-rapply(d, mean, how='list')

this can be run.

mjrf hh
  • 1
  • 1
  • 1
    We don't have `d`, or anything that would let us guess what it looks like. – user2554330 Oct 02 '22 at 23:50
  • 1
    Please make this question *reproducible*. This includes sample *unambiguous* data (e.g., `data.frame(x=...,y=...)` or the output from `dput(head(x))`) and intended output given that input. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Oct 02 '22 at 23:53
  • 1
    I can't replicate this error. The code runs for me. Did you create a variable named `sd` that shadows the base `sd` function? What if you try `rapply(d, stats::sd, how = 'list')` – MrFlick Oct 03 '22 at 00:43
  • @onyambu If you just run `sd <- 5` before this, you'll get the same error. It doesn't have to be a function. `rapply` doesn't call `match.fun()` to specifically find functions. – MrFlick Oct 03 '22 at 00:56
  • @MrFlick you right. Seems rapply does not follow the rules of R. Thanks – Onyambu Oct 03 '22 at 01:02
  • On 2023-07-26 it worked for me. – Avraham Jul 26 '23 at 08:58

0 Answers0