0

I have several phylogenetic GLS and would like to find a better way to summarize the results. I am not using loops to obtain several PGLS since I will be clumping several traits from different matrices. Example below:

library(caper) # for the pgls method
library(dplyr)
library(broom)
library(purrr)

data(shorebird)
birdie <- comparative.data(shorebird.tree, shorebird.data, Species)

pgls.EggVsMass <- pgls( Egg.Mass ~ M.Mass, birdie)
pgls.EggVsClutch <- pgls( Egg.Mass ~ Cl.size, birdie)

SUM.EggVsMass <- summary(pgls.EggVsMass)$coefficients
SUM.EggVsClutch <- summary(pgls.EggVsClutch)$coefficients

GL <- mget(ls(pattern = "SUM.*"))

tidier <- GL  %>%  purrr::map(., glance)

But the object 'tidier' is not a simple tibble and I can't properly save it. How can I improve this strategy and obtain a tibble with the information in the summary or the coefficients ?

A similar code but for lm worked so I would like to solve the PGLS in a similar way. Using map_df in the case above does not work.

LMTRAIT <- names(data)[-1] %>% 
  paste('trait1 ~', .) %>%    
  map(lm, data) %>% 
  purrr::map_df(., broom::glance) # 
as_tibble(LMTRAIT)
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
Andrés Parada
  • 319
  • 7
  • 21

1 Answers1

0

I found the solution to this through map_chr::repurrrsive

If I want the intercept of every trait I would have to obtain

GL$SUM.EggVsClutch[1]
GL$SUM.EggVsMass[1]

this is with map_chr

library(repurrrsive)
as_tibble(map_chr(GL, 1))
Andrés Parada
  • 319
  • 7
  • 21