[R] using MAP and PURR to compute characteristic roots

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Thu Apr 1 02:46:26 CEST 2021

Since purrr:map() is functionally identical to lapply, it is not at all clear to me what you are having trouble with. What output did you want?

On March 31, 2021 5:10:29 PM PDT, Veerappa Chetty <chettyvk using gmail.com> wrote:
>I have to compute characteristic roots for 100s of U.S.counties.  I got
>help using " lapply". I prefer using MAP and PURR if that is possible.
>I am
>using them to compute linear regressions.
>Here is my test problem and the output. I would appreciate any help.
>test.dat<- tibble(ID=c(1,2),a=c(1,1),b=c(1,1),c=c(2,2),d=c(4,3))
>test.out<-test.dat %>% nest(-ID) %>% mutate(fit = purrr::map(data,~
>function(x) eigen(data.matrix(x)), data=.))
>I get this output:
>> test.out$fit
>function(x) eigen(data.matrix(x))
><environment: 0x0000017d35f00518>
>function(x) eigen(data.matrix(x))
><environment: 0x0000017d35ef73d0>
>	[[alternative HTML version deleted]]
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

Sent from my phone. Please excuse my brevity.

More information about the R-help mailing list