This number is how many trees they pointlessly looked at again after already getting the fruit - it corresponds with memory errors.
e2 Revisits: Prepare the data
Read in the data and pre-process it.
Show the code
e2 <-readRDS("002-00-e2-data.RDS")# remove things from the raw data to make it # suitable for this particular analysis# remove samples that did not look at a treee2 <- e2 %>%filter(fl>0)# remove the second (and any subsequent) *consecutive* duplicatese2 <- e2 %>%group_by(pp, rr, tb) %>%filter(is.na(tl !=lag(tl)) | tl !=lag(tl)) %>%ungroup()# remove trials where they failed to get 14 fruite2 <- e2 %>%group_by(pp, rr, tb) %>%mutate(max_fr =max(fr)) %>%ungroup() %>%filter(max_fr==14) %>%select(-c(ex, max_fr, st, xx, yy, ln)) # currently some trials don't have entries for fruit of zero# these trials are where they found a fruit on the first tree# We want to say that these were:# number of revisits = 0 # (not number of revisits = "a structural missing")design <-tibble(expand.grid(pp=unique(e2$pp),rr=unique(e2$rr),tb=unique(e2$tb),fr=0 ) )design <-left_join( design, e2 %>%group_by(pp) %>%summarise(ff=unique(ff)),join_by(pp) )e2 <-full_join( design, e2,join_by(pp, rr, tb, fr, ff) ) %>%arrange(pp, rr, tb, fr)# annotate with revisite2 <- e2 %>%group_by(ff, pp, rr, tb) %>%mutate(isrv =duplicated(tl)) %>%ungroup() # get number of revisits per fruit# (is how many times they looked at a tree that # they saw before on this trial on the way to # getting this particular fruit)e2 <- e2 %>%select(ff, pp, rr, tb, fr, isrv) %>%group_by(ff, pp, rr, tb, fr) %>%summarise(nrv=sum(isrv)) %>%ungroup()# add the stage IVe2 <- e2 %>%mutate(st =ifelse(tb<=10, "early", "late") ) %>%select(ff, pp, rr, st, tb, fr, nrv)# factorse2 <- e2 %>%mutate(ff=as_factor(ff), pp=as_factor(pp), rr=as_factor(rr), st=as_factor(st)) %>%ungroup()# collapse over trials - what was the average number of revisits for this fruit,# now that the absence of visits to trees while fr was zero contributes a zero# not a structural missing. Also prune entries for fr == 14 which are all # constrained to be zeronrev_data_for_aov <- e2 %>%group_by(ff, pp, rr, st, fr) %>%summarise(nrv=mean(nrv)) %>%filter(fr!=14) %>%mutate(fr=as_factor(fr)) %>%ungroup()# collapse over trials to yield a value for each fruitnrev_data_for_ggplot <- e2 %>%group_by(ff, pp, rr, fr) %>%summarise(nrv=mean(nrv)) %>%filter(fr!=14) %>%mutate(fr=as_factor(fr)) %>%ungroup()saveRDS(nrev_data_for_ggplot, "e2_nrevisits_plot_data.rds")
e2 Revisits: ANOVA
2 x 2 * 2 * 10
A 2x2x2x10 ANOVA with the within factors resource distribution (patchy, dispersed) and trial (early [mean trials 1-5], late [mean trials 6-10]); between fading; and as dv number of fruit consumed (1-10)
pre.means = nrev_data_for_aov %>%group_by(fr, pp, st) %>%# average over resourcessummarise(mean.nrv=mean(nrv)) %>%group_by(fr, pp) %>%# average over stagesummarise(mean.nrv=mean(mean.nrv))ok.means = pre.means %>%group_by(fr) %>%summarise(mean=mean(mean.nrv), sd=sd(mean.nrv))prettify_means(ok.means, "e2 Nrevisits fruit means")