I am trying to present linear regressions of two datasets on the same plot.
- Bird data vs year
- Signy data vs year As they are exclusive to each other (count data from two islands) I don't want to plot a multiple regression, but I am not sure the code in R to produce both regressions on the same plot.
PlasticMass.data
ï..Year |Bird.Plastic.Mass Signy.Plastic.Mass
1 1991 | NA | 2.384
2 1992 | NA | 8.340
3 1993 | NA | 2.680
4 1994 | NA | 1.450
5 1995 | NA | 1.940
6 1996 | 6.43 | 0.570
7 1997 | 19.86| 1.170
8 1998 | 4.89 | 2.010
9 1999 | 2.97 | 1.410
10 2000 | 3.10 | 1.690
11 2001 | 3.30 | 0.350
12 2002 | 4.45 | 9.280
13 2003 | 4.05 | 16.750
14 2004 | 2.18 | 4.330
15 2005 | 4.88 | 0.260
16 2006 | 4.39 | 13.500
17 2007 | 4.27 | 6.270
18 2008 | 4.40 | 9.030
19 2009 | 1.63 | 3.860
20 2010 | 1.70 | 22.100
21 2011 | 1.64 | 1.150
22 2012 | 2.16 | 13.080
23 2013 | 3.05 | 0.140
24 2014 | 1.34 | 0.010
25 2015 | 3.66 | 0.000
26 2016 | 0.87 | 0.000
27 2017 | 1.10 | 7.010
28 2018 | 2.29 | 1.740
29 2019 | 1.44 | 80.790
R code to plot individual regressions: Plastic by mass linear regressions
PlasticMass.data <-read.csv("Plastic by Mass.csv", header = T)
print(Plastic.Mass.data)
modelPB <-lm(Bird.Plastic.Mass ~ï..Year, data= PlasticMass.data)
modelPS <-lm(Signy.Plastic.Mass ~ï..Year, data = PlasticMass.data)
ggplot(PlasticMass.data, aes(ï..Year, Bird.Plastic.Mass))+
geom_point()+
geom_smooth(method = "lm")+
labs(x="Year", y="Bird Island Total Debris Count")
ggplot(PlasticMass.data, aes(ï..Year, Signy.Plastic.Mass))+
geom_point()+
geom_smooth(method = "lm", colour ="lightgreen")+
labs(x="Year", y="Signy Island Total Debris Count")
Here is a link to show the regression plot I made on excel (where both datasets are plotted and the separate linear regressions are shown).
