Code/00_base_results_fun.R

# Function to do all the basic results
#for inline Rcode

function(){

  #simple min number of captures data
  source(here::here("R/wrangling/Data_CRinput_mice_jan2019.R", echo = FALSE))

  #simple min number of captures
  min.mice <- group_by(ind, valley, grid.id, grid, trip.no) %>%
    summarise(recap = sum(recap),
              n = n())

  #renaming datasets for ease
  dat_raw_caps <- min.mice
  start <- c("January 1999")
  end <- c("June 2001")

  #import ploting data
  plot.dat.all1 <- read_csv("./data/plot-all-data1.csv")

  # source("./R/Davidson_2019_Data_wrangling2.R")
  dat_all_output <- read_csv("./data/plot-all-data1.csv")
  # names(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) %>%
    mutate(grid = factor(paste(Control, Valley)),
           Conditions = factor(Conditions, labels = c("Rats unmodified", "Rats removed")))

  # names(dat_all_output)

  seed_N_144_summary <- plot.dat.all1 %>%

    select(cum.seed, Control, Valley, year, Date, Conditions) %>%

    mutate(year = as.factor(year)) %>%

    group_by(Control, Valley, Date, Conditions) %>%
    summarise(N = mean(ifelse(cum.seed > 0, ifelse(cum.seed > 0, log(cum.seed), 0), 0)),
              Rats = factor("ALL"),
              sd.s = sd(ifelse(cum.seed > 0, log(cum.seed), 0), na.rm = TRUE),
              se.s = sd(ifelse(cum.seed > 0, log(cum.seed), 0)) / sqrt(length(cum.seed)) * 1.96,
              lcl.s = mean(ifelse(cum.seed > 0, log(cum.seed), 0)) - (sd(ifelse(cum.seed > 0, log(cum.seed), 0)) / sqrt(length(cum.seed)) *
                                                                        1.96),
              lcl_seed = exp(lcl.s),
              ucl.s = mean(ifelse(cum.seed > 0, log(cum.seed), 0)) + (sd(ifelse(cum.seed > 0, log(cum.seed), 0)) / sqrt(length(cum.seed)) *
                                                                        1.96),
              ucl_seed = exp(ucl.s), mean_seed = exp(N)) %>%
    ungroup() %>%
    mutate(mean_seed = N)

}
davan690/beech-publication-wr documentation built on March 29, 2020, 11:09 a.m.