Re: [R] $ subset operator behavior in lapply

2022-10-28 Thread Hilmar Berger
Hi Andrew, thanks a lot, that fully explains it. Sorry for the HTML text. For the record I put the original code again below. Best regards Hilmar On 27.10.22 18:34, Andrew Simmons wrote: > $ does not evaluate its second argument, it does something like > as.character(substitute(name)). > >

Re: [R] $ subset operator behavior in lapply

2022-10-27 Thread Jeff Newmiller
Your message is garbled. Please send plain text to the mailing list. On October 27, 2022 2:31:47 AM PDT, Hilmar Berger wrote: >Dear all, > >I'm a little bit surprised by the behavior of the $ operator when used >in lapply - any indication what might be wrong is appreciated. > >> xx =

Re: [R] $ subset operator behavior in lapply

2022-10-27 Thread Andrew Simmons
$ does not evaluate its second argument, it does something like as.character(substitute(name)). You should be using lapply(list, function(x) x$a) or lapply(list, `[[`, "a") On Thu, Oct 27, 2022, 12:29 Hilmar Berger wrote: > Dear all, > > I'm a little bit surprised by the behavior of the $

[R] $ subset operator behavior in lapply

2022-10-27 Thread Hilmar Berger
Dear all, I'm a little bit surprised by the behavior of the $ operator when used in lapply - any indication what might be wrong is appreciated. > xx = list(A=list(a=1:3, b=LETTERS[1:3]),"B"=list(a=7:9, b=LETTERS[7:9])) > > lapply(xx,`$`,"a") $A NULL $B NULL > `$`(xx[[1]],"a") [1] 1 2 3 >