The Euclidian distance between successive tree-visits, in units of pixels.
E1 Distance - Prepare the data
Read the data and pre-process it.
Show the code
e1 <-readRDS("001-00-e1-data.RDS")# remove things from the raw data to make it # suitable for this particular analysis# remove samples that did not look at a treee1 <- e1 %>%filter(fl>0)# remove the second (and any subsequent) *consecutive* duplicatese1 <- e1 %>%group_by(pp, rr, tb) %>%filter(is.na(tl !=lag(tl)) | tl !=lag(tl)) %>%ungroup()# remove trials where they failed to get 10 fruite1 <- e1 %>%group_by(pp, rr, tb) %>%mutate(max_fr =max(fr)) %>%ungroup() %>%filter(max_fr==10)# Euclide1 <- e1 %>%group_by(pp, rr, tb) %>%mutate(dist =round(sqrt((lead(xx)-xx)^2+ (lead(yy)-yy)^2), 2)) %>%ungroup()# timee1 <- e1 %>%group_by(pp, rr, tb) %>%mutate(tm=tm-first(tm)) %>%ungroup()# fewer columnse1 <- e1 %>%select(pp, rr, st, tb, tm, ll, tl, dist)e1 <- e1 %>%mutate(pp =as_factor(pp), st=as_factor(st), tb=as_factor(tb),ll=factor(ll, levels=c("fruit", "not"), labels=c("Launched from fruit", "Launched from tree without fruit" )),rr=factor(rr, levels=c("dispersed", "patchy")), )dst <- e1 %>%group_by(pp, rr, st, ll, tb) %>%# average over tree-visits yielding# two values for each trial, # one for launch from fruit, # one for launch from emptysummarise(dist=mean(dist, na.rm=TRUE)) %>%arrange(pp, rr, st, ll, tb, .by_group =TRUE) %>%ungroup()# average over trials in each of the two stages,# to yield one row for each launch type, per stage# 8 rows per subject, 2 x 2 x 2# 2 x 2 x 2 x 42=336 rowsdst <- dst %>%group_by(pp, rr, st, ll) %>%summarise(mu.dist=mean(dist, na.rm=TRUE)) %>%ungroup()dst <- dst %>%select(rr, st, ll, pp, mu.dist) %>%arrange(rr, st, ll, pp, mu.dist)saveRDS(dst, "e1_distance_data.rds")
The effect of resources was F(1, 41) = 13.09, p<.001.
The effect of stage was F(1, 41) = 6.18, p<.05.
The effect of stage was F(1, 41) = 31.62, p<.001.
The effect of the interaction resources x stage x launch was F(1, 41) = 11.62, p<.01.
E1 Distance: Plot
x axis is stage; y axis is distance; group is resources; panel is launch site type
Show the code
ggplot(data=dst, aes(y=mu.dist, x=st, group=rr, fill=rr, shape=rr)) +facet_wrap(~ll) +labs(title="(d): Distance moved between trees", subtitle ="The eyes move further to the next tree if the current tree has no fruit")+ylab("Pixels")+xlab("Trials")+ my_fgms_theme+scale_fill_manual(name="Resource\ndistribution",values=c("white", "black")) +scale_shape_manual(name="Resource\ndistribution",values=c(24,19)) +stat_summary(fun.data = mean_cl_normal, geom ="errorbar", width=0.1, position=pd) +stat_summary(fun = mean, geom ="line", position=pd) +stat_summary(fun = mean, geom ="point", size=3, position=pd)+scale_x_discrete(labels=c("early trials\n1 to 5", "late trials\n6 to 10"))
E1 Distance means
Stage means for patchy no-fruit increase over trials as subjects learn over the course of the experiment to move further when they are less likely to be in a patch, and to stay within fruitful areas (area restricted search)
Show the code
dst %>%filter(rr=="patchy", ll=="Launched from tree without fruit") %>%group_by(st) %>%summarise(mean=mean(mu.dist), sd=sd(mu.dist)) %>%gt() %>%fmt_number(decimals=0) %>%tab_header("Pixels for patchy no-fruit")