using MAP and PURR to compute characteristic roots
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 at 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. Thanks V.K.Chetty ____ 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
[[1]] function(x) eigen(data.matrix(x)) <environment: 0x0000017d35f00518> [[2]] function(x) eigen(data.matrix(x)) <environment: 0x0000017d35ef73d0> [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Sent from my phone. Please excuse my brevity.