I have a simple dataset that I want to iterate the dependent variable using aov and tidyverse. From those outputs I then want to compute Tukey HSD tests. I have this working in a for loop structure, but am trying my hardest to migrate from that mentality. I saw this post on iterating aovfunctions with the independent variables. Tried to incorporate this logic into my workflow, but not working out so well. Any tidyverse aficionados that could steer me in the right direction here?
library(tidyverse)
library(data.table)
pfuel <- fread("data/CFL.csv") %>%
mutate(AFCL = AFCL*10,
LCW = LCW*10,
DCW = DCW*10,
LiDe = ifelse(Status == "Li", "Live", "Dead")) %>%
filter(S.F == "S") %>%
group_by(Site, Year, Age, Plot) %>%
select(LiFol, DeFol, Li.1hr, De.1hr, Li.10hr, De.10hr, Li.100hr, De.100hr) %>%
summarise_all(sum) %>%
ungroup() %>%
mutate(sb_age = paste0(Year, Age))
aov.models = pfuel %>%
select (-c(Year, Age)) %>%
select(LiFol, DeFol, Li.1hr, De.1hr, Li.10hr, De.10hr, Li.100hr, De.100hr, Site, Plot, sb_age) %>%
map(~ aov(.x ~ sb_age + Site/Plot, data = pfuel))
When the aov.models runs I generate this error:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf in 'y'
In addition: Warning message:
In model.response(mf, "numeric") : NAs introduced by coercion
I haven't gotten to the Tukey test yet, as I cannot get past the aov function. Any suggestions would be GREATLY appreciated!
You can find the data here: https://www.dropbox.com/s/yb8rh860fc7fff2/CFL.csv?dl=0
Thanks!
pfuel$...- I'm pretty sure you don't want to be referencing anything usingpfuel$really whenaov(formula, data=.)or some similar construction could be used. - thelatemailselect()statements. If one is excluding certain variables, but then you just select a specified list, why bother with the initial exclusion? - thelatemailselect()call. When you reachaov(Site~ sb_age + Site/Plot, data = pfuel)&aov(sb_age ~ sb_age + Site/Plot, data = pfuel), do you still get output without error? - Z.Lin