##R script ## Packages library(lme4) library(lsmeans) library(dplyr) library(car) library(tidyr) library(visreg) # Nectar ------------------------------------------------------------------ ##Nectar production during anthesis. We evaluated the production of nectar during anthesis by analyses of variance (one-way ANOVA), using the function aov anthesis<-read.table("nectar.anthesis.txt", header = TRUE) ## Before conduted the Anova we test the normality using the function shapiro.test shapiro.test(anthesis$mg) ## We used the function aov to run the Anova b1<-aov(anthesis$mg~anthesis$period) summary(b1) ##Nectar production along the anthesis analysed by linear model, as the reviewer suggested. m1<-lm(anthesis$mg~anthesis$period) car::Anova(m1, type = "II", test.statistic = "F") summary(m1) m1 ##Effect of nectar removal #We evaluated the effect of nectar removal by Anova. ## For this, we used the function aov removal<-read.table("nectar.removal.txt", header = TRUE) ## Before conduted the Anova we test the normality using the function shapiro.test shapiro.test(removal$mg) ## We used the function aov to run the Anova a2<-aov(removal$mg ~ removal$treatment) summary(a2) # We assessed the differences between treatments (time of anthesis and number of removals R1, R2, and R3) by Tukey HSD post-hoc test, using the function TukeyHSD TukeyHSD(a2, "removal$treatament") ##Effect of nectar removal analysed by linear model, as the reviewer suggested. m2<-lm(removal$mg~removal$treatment) car::Anova(m2, type = "II", test.statistic = "F") summary(m2) m2 # Reproductive success after natural pollination --------------------------- ## We conducted a linear model to evaluate if the reproductive success after natural pollination varied between three reproductive events (2016, 2017, and 2018) C1<-read.table("natural conditions.txt", header = TRUE) C1$year<-as.factor(C1$year) C1$individuals<-as.factor((C1$individuals)) ### Prior to analyses, we cubic-root transformed values of the response variable to meet the normality assumptions. ### We used the reproductive events (three levels: 2016, 2017, and 2018) as fixed effect. We established the model using the function lm. model1<-lm(success^(1/3) ~year, data=C1) ## we tested the model assumptions by visual inspection of the residuals using the qqnorm function. hist(resid(model1)) qqnorm(residuals(model1, type = "deviance"));qqline(residuals(model1, type = "deviance")) #We calculated the significance of each term in the model using the function Anova (Type II) from the car package. Anova(model1, type = "II", test.statistic = "F") ## we calculated the differences between levels of categorical factors using the function lsmeans from lsmeans package. lsmeans(model1, pairwise ~ year, data=C1) # Efficacy among functional group of pollinators -------------------------- ## To evaluate whether hummingbirds and large bees differ in their efficacy, we conducted a linear model. d1<-read.table("efficacy.txt", header = TRUE) d1$year<-as.factor(d1$year) d1$individuals<-as.factor(d1$individuals) # Prior to analyses, we cubic-root transformed values of the response variable to meet the normality assumptions. ## We used the functional group of pollinators (two levels: hummingbirds and large bees) and the year when the treatments were conducted (two levels: 2017 and 2018) as fixed effects. ### We established the model using the function lm model2<-lm(success^(1/3) ~ group*year, data=d1) ## we tested the model assumptions by visual inspection of the residuals using the qqnorm model2@theta qqnorm(residuals(model2, type = "deviance"));qqline(residuals(model2, type = "deviance")) summary(model2) ## We calculated the significance of each term in the model using the function Anova (Type II) from the car package. Anova(model2, type = "II", test.statistic = "F") ## We calculated the differences between levels of categorical factors using the lsmeans package. lsmeans(model2, pairwise ~ group, data=d1) lsmeans(model2, pairwise ~ year, data=d1) # Frequency of visits ----------------------------------------------------- ## we conducted a log-linear model for categorical data to evaluated to evaluate if the frequency of visits varies between the four reproductive events and the group of floral visitors dado1<-read.table("frequency_of_visits.txt", header = TRUE) dado1$year<-as.factor(dado1$year) shapiro.test(dado1$freq) bartlett.test(dado1$freq~dado1$year) table(dado1$year, dado1$year) ## We used the relative frequency of visits as a response variable, and the reproductive events (four levels: 2015, 2016, 2017, and 2018) and the functional groups (three levels: hummingbirds, large bees, and small bees) as fixed effects. ### We established the model using the glm function with the family set to poisson foo <- glm(freq ~ year * group, "poisson", data = dado1) Anova(foo, type = 3) summary(foo) ## We tested the model assumptions by visual inspection of the residuals. qqnorm(resid(foo));qqline(resid(foo)) plot(dado1$freq ~ predict(foo, type = "response")) predict(foo, type = "response") dado1$freq # We calculated the significance of each term in the model using the anova function (test = Chisq). anova(foo, test = "Chisq") plot(foo) ## We calculated the differences between levels of categorical factors using the emmeans function available in the emmeans package. valores <- emmeans(foo, ~ year + group, type = "response") contrast(valores, "pairwise", adjust = "none")