# The R code used to make each figure and perform each analysis. # The code for the GLM relating aphid abundance on each plant to the number of ants found on the plant. (Fig 1 a-c) glm(NumAntsOnLeaves ~ NumAphOnLeaves,family=poisson,data= year2011)) glm(NumAntsOnLeaves ~ NumAphOnLeaves,family=poisson,data= year2012)) glm(NumAntsOnLeaves ~ NumAphOnLeaves,family=poisson,data= year2013)) # The code for the GLM relating aphid abundance on each plant to the number of ants found on the plant. (Fig 1 d-f) glm(NumOfAntsInFlowers ~ NumAntsOnLeaves,family=poisson,data= year2011)) glm(NumOfAntsInFlowers ~ NumAntsOnLeaves,family=poisson,data= year2012)) glm(NumOfAntsInFlowers ~ NumAntsOnLeaves,family=poisson,data= year2013)) # The code for the GLM relating pollinator visit duration to ant floral presence for all pollinators and just honeybees. (Fig 2) glm(CumulativePollinatorDurationInFlowers~ NumOfAntsInFlowers, family=poisson,data=allyears) glm(CumulativePollinatorDurationInFlowers~ NumOfAntsInFlowers, family=poisson,data=onlyHoneybees) # The code for the GLM relating aphid abundance to plant reproductive characteristics. (Fig 3) s1<-(glm(NumSeeds~NumAph,family=poisson,data=year2011)) s2<-(glm(SeedWeightInGRAMS~NumAph,family=poisson,data= year2011)) cor(fitted(s1), year2011$NumSeeds)^2 cor(fitted(s2), year2011$SeedWeightInGRAMS)^2 s3<-(glm(NumSeeds~NumAph,family=poisson,data= year2012)) s4<-(glm(SeedWeightInGRAMS~NumAph,family=poisson,data= year2012)) cor(fitted(s3), year2012$NumSeeds)^2 cor(fitted(s4), year2012$SeedWeightInGRAMS)^2 s5<-(glm(NumSeeds~NumAph,family=poisson,data=year2013)) s6<-(glm(SeedWeightInGRAMS~NumAph,family=poisson,data= year2013)) cor(fitted(s5), year2013$NumSeeds)^2 cor(fitted(s6), year2013$SeedWeightInGRAMS)^2