[R] using eigen function in MAP and purr

Veerappa Chetty chettyvk @end|ng |rom gm@||@com
Mon Mar 29 23:28:51 CEST 2021


I want to use map and purr functions to compute eigen values for 3000
matrices. Each matrix has 2 rows and 2 columns. The following code does not
work.

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(matrix(x,2,2)), data=.))

This must be a trivial question for current young practitioners ( In my 9
th decade, I am having fun using R markdown and I am trying to continue my
research!) I would greatly appreciate any help.
Thanks.
V.K.Chetty
-- 
Professor of Family Medicine
Boston University

	[[alternative HTML version deleted]]



More information about the R-help mailing list