--- title: "R Notebook" output: html_notebook --- This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Cmd+Shift+Enter*. ```{r} plot(cars) library("readr") IsosWA3 <- read.csv("~/Dropbox/Sgro Lab/PEOPLE/Avi/Chapter 3/Selected_lines_exps/Female_adult_wing_area_final.csv") head (IsosWA3) ``` ```{r} require(dplyr) library(lme4) library(emmeans) library (ggplot2) IsosWA3$Line <- as.factor(IsosWA3$Line) ``` ```{r} IsosWA.lm3 <- lmer (Wing_area ~ 1+ Temp * Conc + (1|Replicate) + (1|Line) , data = IsosWA3) summary (IsosWA.lm3) car::Anova(IsosWA.lm3) IsosWA.lm4 <- lmer (Wing_area ~ Temp * Diet *Line + (1|Replicate) , data = IsosWA3) summary (IsosWA.lm4) car::Anova(IsosWA.lm4) IsosWA.lm5 <- lm (Wing_area ~ Temp * Conc *Line + (1|Replicate) , data = IsosWA3) summary (IsosWA.lm5) car::Anova(IsosWA.lm5) anova (IsosWA.lm5, IsosWA.lm4) #checking for plasticity level group differences IsosWA.lm6 <- lmer (Wing_area ~ Temp * Conc *PL + (1|Replicate) + (1|Line) , data = IsosWA3) summary (IsosWA.lm6) car::Anova(IsosWA.lm6) Isos_trend <- emtrends(IsosWA.lm5, ~ Temp | Line, var = "Conc") multcomp::cld(Isos_trend) #line 36 differ in response of diet at the two temperature, steeper response to diet at 25 than 28 ``` ```{r} PLOT3 <- ggplot(data = IsosWA3, aes(x=Conc, y=Wing_area, group=Line, colour=as.factor(PL)))+ theme_bw()+ #theme(panel.grid=element_blank(),axis.title.x=element_text(size=16), axis.title.y=element_text(size=16), axis.text.y=element_text(size=16), axis.text.x=element_text(size=12), legend.background = element_rect(), legend.key = element_rect(colour = "white"), legend.text=element_text(face="italic", size=12))+ #scale_colour_hue(name = "line_number") + #theme(legend.title=element_blank())+ expand_limits(x=0.1) + #geom_point(size=2.5) + #geom_line(data=IsosWing, aes(x=Diet_dilution, y=wing_area, group=Line),stat="smooth",method = "loess",size = 1,alpha = 0.1)+ geom_smooth( method="lm", se=FALSE)+ #geom_smooth (method="lm",formula = y ~ poly(x,2,raw=TRUE), se = FALSE, aes (fill = as.factor (Line)))+ scale_x_continuous( breaks = c (12.5, 100))+ scale_y_continuous (limits= c(0.65,1.25), breaks = seq (0.65, 1.25, 0.1)) + geom_point (alpha=0.3)+ geom_jitter() + #scale_x_continuous( breaks = seq (12.5, 25, 100))+ #guides (fill=FALSE) + #geom_smooth for black line mean facet_grid(~ Temp)+ xlab("Diet_dilution")+ylab("Wing area ")+ geom_blank() PLOT3 pdf("./WingAreaSelectedLines_response_PLgroup.pdf", useDingbats=FALSE) grid.arrange(PLOT3) dev.off() ``` Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Cmd+Option+I*. When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Cmd+Shift+K* to preview the HTML file). The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike *Knit*, *Preview* does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.