Code/06-raw-mice-results.R

#function for importing information for bsaic manuscript results
#Anthony 
#March2020

library(extrafont)
# this just simply reduces long name to "Times" as in code below
windowsFonts(Times = windowsFont("TT Times New Roman"))

#data needed
#results from bayesian model
dat_all_output <- read_csv("./data/plot-all-data1.csv")

#function
raw_estimates_mice_func <- function(dat_all_output = dat_all_output){

###summaries for inline chuncks below:
mouse_N_144_summary <- dat_all_output %>%
        select(N,se.N, lcl.N, ucl.N, Valley, Control, Conditions, var, year, Date, trip, grid) %>%
            mutate(grid.id = factor(paste(Control, Valley)),
                    Conditions = factor(Conditions, labels = c("Rats unmodified", "Rats removed"))
                    )

return(mouse_N_144_summary)
} #function end



#example
mouse_N_144_summary <- raw_estimates_mice_func(dat_all_output)


# str(mouse_N_144_summary$grid.id)
mouse_N_40_summary <-  mouse_N_144_summary %>%
  group_by(Control, Valley, Date) %>%
  summarise(N = mean(N),
            Rats = factor("Full", levels = c("Full", "Reduced"))) %>%
  ungroup() %>%
  mutate(grid = factor(paste(Control, Valley)))


# summary for plots
# create summarised datasets of need
mouse_N_40_summary <- mouse_N_144_summary %>%
  group_by(Control,Valley, trip) %>%
  summarise(N.count = n(),
            N = mean(N, rm.na = TRUE),
            tvalue = qt(p = 0.025, df = N.count - 1, lower.tail = FALSE),
            low.se = mean(se.N),
            lcl.low.tv = N - (tvalue*low.se),
            ucl.low.tv = N + (tvalue*low.se),
            lcl.low = N - (1.96*low.se),
            ucl.low = N + (1.96*low.se))


##extraas I think
mouse_N_80_summary <- mouse_N_144_summary %>%
  group_by(Control,Valley,Conditions, Date)  %>%
  summarise(N.count = n(),
            N = mean(N, rm.na = TRUE),
            tvalue = qt(p = 0.025, df = N.count - 1, lower.tail = FALSE),
            low.se = mean(se.N),
            lcl.low.tv = N - (tvalue*low.se),
            ucl.low.tv = N + (tvalue*low.se),
            lcl.low = N - (1.96*low.se),
            ucl.low = N + (1.96*low.se))
davan690/beech-publication-wr documentation built on March 29, 2020, 11:09 a.m.