library(ggplot2)
library(cowplot)
library(dplyr)
library(r2symbols)
library(gridExtra)
curvas=read.csv("D:\\Armazenamento\\DATA R\\EDXRF\\curva.csv")
curvas
curvas$matriz=as.factor(curvas$matriz)
curvas$marker=as.factor(curvas$marker)
View(curvas)
str(curvas)
'data.frame': 24 obs. of 5 variables:
$ matriz : Factor w/ 2 levels "Feces","Hay": 2 2 2 2 2 2 2 2 2 2 ...
$ marker : Factor w/ 2 levels "Cr","Ti": 1 1 1 1 1 1 2 2 2 2 ...
$ add : num 0 5378 9810 19152 27398 ...
$ cps.RhKaC: num 0 1.36 2.48 3.9 5.67 ...
$ cps : num 0 6.72 11.71 18.94 24.93 ...
d1=curvas[c(7:12),]
d1
m1.1=lm(cps~add,data=d1)
summary(m1.1)
Call:
lm(formula = cps ~ add, data = d1)
Residuals:
7 8 9 10 11 12
-0.19090 -0.07435 0.19076 0.07520 0.34284 -0.34354
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.909e-01 1.874e-01 1.019 0.366
add 5.586e-04 9.243e-06 60.431 4.49e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.2827 on 4 degrees of freedom
Multiple R-squared: 0.9989, Adjusted R-squared: 0.9986
F-statistic: 3652 on 1 and 4 DF, p-value: 4.491e-07
plot1=ggplot(d1,aes(x=add,y=cps))+
geom_smooth(color='black', method='lm', formula=y ~ x, se=T,size=0.25)+geom_point(size = 1)+
scale_x_continuous(name=expression(paste("Ti concentration (mg k",g^-1,")")),
breaks = seq(0,40000,5000), limits = c(0, 40000))+
scale_y_continuous(name=expression(paste("Ti K",alpha," intensity (cps ",mu, "",A^-1,")")),breaks=seq(0,30,2), limits = c(0, 22))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.25),
axis.title.x = element_text(size = 14, color = "black"),
axis.title.y = element_text(size = 14, color = "black"),
axis.text.x = element_text(size = 12, angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 12, color = "black"))+
annotate(geom="text", y=8, x=28000,
label=expression(paste("y = 0.000559x + 0.19")),size=5,color="black")+
annotate(geom="text", y=6.5, x=28000,label=expression(paste(R^2, " = 0.998")),size=5,color="black")+
annotate(geom="text", y=22, x=0,label="A",size=7,color="black")+
coord_fixed(ratio = 40000/22)
plot1
d2=curvas[c(1:6),]
d2
m2.1=lm(cps~add,data=d2)
summary(m2.1)
Call:
lm(formula = cps ~ add, data = d2)
Residuals:
1 2 3 4 5 6
-2.1530 0.2309 1.6389 1.3394 0.6722 -1.7284
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.153e+00 1.191e+00 1.808 0.144886
add 8.067e-04 5.829e-05 13.840 0.000158 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.775 on 4 degrees of freedom
Multiple R-squared: 0.9795, Adjusted R-squared: 0.9744
F-statistic: 191.5 on 1 and 4 DF, p-value: 0.000158
plot2=ggplot(d2,aes(x=add,y=cps))+
geom_smooth(color='black', method='lm', formula=y ~ x, se=T, size=0.25)+geom_point(size = 1)+
scale_x_continuous(name=expression(paste("Cr concentration (mg k",g^-1,")")),
breaks = seq(0,40000,5000), limits = c(0, 40000))+
scale_y_continuous(name=expression(paste("Cr K",alpha," intensity (cps ",mu, "",A^-1,")")),breaks=seq(0,30,2), limits = c(0, 30))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.25),
axis.title.x = element_text(size = 14, color = "black"),
axis.title.y = element_text(size = 14, color = "black"),
axis.text.x = element_text(size = 12, angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 12, color = "black"))+
annotate(geom="text", y=10, x=28000,label=expression(paste("y = 0.00081x + 2.2")),size=5,color="black")+
annotate(geom="text", y=8.2, x=28000,label=expression(paste(R^2, " = 0.979")),size=5,color="black")+
annotate(geom="text", y=30, x=0,label="B",size=7,color="black")+
coord_fixed(ratio = 40000/30)
plot2
a=grid.arrange(plot1,plot2,ncol = 2)
ggsave("Plot hay curves.png", a, width = 10, height = 5, units = "in", dpi = 300)
d4=curvas[c(7:12),]
d4
m4=lm(cps.RhKaC~add,data=d4)
summary(m4)
Call:
lm(formula = cps.RhKaC ~ add, data = d4)
Residuals:
7 8 9 10 11 12
0.056223 -0.003403 0.019567 -0.185506 0.083748 0.029372
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -5.622e-02 7.096e-02 -0.792 0.473
add 1.306e-04 3.501e-06 37.304 3.08e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.1071 on 4 degrees of freedom
Multiple R-squared: 0.9971, Adjusted R-squared: 0.9964
F-statistic: 1392 on 1 and 4 DF, p-value: 3.084e-06
plot4=ggplot(d4,aes(x=add,y=cps.RhKaC))+
geom_smooth(color='black', method='lm', formula=y ~ x, se=T,size=0.25)+geom_point(size = 1)+
scale_x_continuous(name=expression(paste("Ti concentration (mg k",g^-1,")")),
breaks = seq(0,40000,5000), limits = c(0, 40000))+
scale_y_continuous(name=expression(paste("Ti K",alpha," Rh K",alpha," ",Compton^-1,"")),breaks=seq(0,6,1), limits = c(0, 6))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.25),
axis.title.x = element_text(size = 14, color = "black"),
axis.title.y = element_text(size = 14, color = "black"),
axis.text.x = element_text(size = 12, angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 12, color = "black"))+
annotate(geom="text", y=1.8, x=30000,
label=expression(paste("y = 0.000131x - 0.06")),size=5,color="black")+
annotate(geom="text", y=1.3, x=30000,label=expression(paste(R^2, " = 0.997")),size=5,color="black")+
annotate(geom="text", y=6, x=0,label="A",size=7,color="black")+
coord_fixed(ratio = 40000/6)
plot4
d5=curvas[c(1:6),]
d5
m5=lm(cps.RhKaC~add,data=d5)
summary(m5)
Call:
lm(formula = cps.RhKaC ~ add, data = d5)
Residuals:
1 2 3 4 5 6
-0.29830 0.04736 0.32023 -0.03343 0.18258 -0.21843
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.983e-01 1.762e-01 1.693 0.166
add 1.895e-04 8.623e-06 21.980 2.54e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.2626 on 4 degrees of freedom
Multiple R-squared: 0.9918, Adjusted R-squared: 0.9897
F-statistic: 483.1 on 1 and 4 DF, p-value: 2.535e-05
plot5=ggplot(d5,aes(x=add,y=cps.RhKaC))+
geom_smooth(color='black', method='lm', formula=y ~ x, se=T, size=0.25)+geom_point(size = 1)+
scale_x_continuous(name=expression(paste("Cr concentration (mg k",g^-1,")")),
breaks = seq(0,40000,5000), limits = c(0, 40000))+
scale_y_continuous(name=expression(paste("Cr K",alpha," Rh K",alpha," ",Compton^-1,"")),breaks=seq(0,6,1), limits = c(0, 6))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.25),
axis.title.x = element_text(size = 14, color = "black"),
axis.title.y = element_text(size = 14, color = "black"),
axis.text.x = element_text(size = 12, angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 12, color = "black"))+
annotate(geom="text", y=1.8, x=28000,label=expression(paste("y = 0.000190x + 0.30")),size=5,color="black")+
annotate(geom="text", y=1.3, x=28000,label=expression(paste(R^2, " = 0.992")),size=5,color="black")+
annotate(geom="text", y=6, x=0,label="B",size=7,color="black")+
coord_fixed(ratio = 40000/6)
plot5
a=grid.arrange(plot4,plot5,ncol = 2)
ggsave("Plot Hay compton.png", a, width = 10, height = 5, units = "in", dpi = 300)
d6=curvas[c(13:18),]
d6
m6=lm(cps~add,data=d6)
summary(m6)
Call:
lm(formula = cps ~ add, data = d6)
Residuals:
13 14 15 16 17 18
-0.26960 -0.17113 -0.08381 0.22806 0.67945 -0.38298
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.696e-01 2.377e-01 1.134 0.32
add 7.090e-04 2.701e-05 26.252 1.25e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.4386 on 4 degrees of freedom
Multiple R-squared: 0.9942, Adjusted R-squared: 0.9928
F-statistic: 689.2 on 1 and 4 DF, p-value: 1.251e-05
plot6=ggplot(d6,aes(x=add,y=cps))+
geom_smooth(color='black', method='lm', formula=y ~ x, se=T, size=0.25)+geom_point(size = 1)+
scale_x_continuous(name=expression(paste("Cr concentration (mg k",g^-1,")")),
breaks = seq(0,20000,2500), limits = c(0, 20000))+
scale_y_continuous(name=expression(paste("Cr K",alpha," intensity (cps ",mu, "",A^-1,")")),breaks=seq(0,14,2), limits = c(0, 14))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.25),
axis.title.x = element_text(size = 14, color = "black"),
axis.title.y = element_text(size = 14, color = "black"),
axis.text.x = element_text(size = 12, angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 12, color = "black"))+
annotate(geom="text", y=5.1, x=14000,label=expression(paste("y = 0.00071x + 0.3")),size=5,color="black")+
annotate(geom="text", y=4.1, x=14000,label=expression(paste(R^2, " = 0.994")),size=5,color="black")+
annotate(geom="text", y=14, x=0,label="B",size=7,color="black")+
coord_fixed(ratio = 20000/14)
plot6
d7=curvas[c(19:24),]
d7
m7=lm(cps~add,data=d7)
summary(m7)
Call:
lm(formula = cps ~ add, data = d7)
Residuals:
19 20 21 22 23 24
-0.014895 -0.001455 -0.002277 0.022987 0.003205 -0.007564
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.567e-01 7.832e-03 20.01 3.68e-05 ***
add 3.983e-04 8.779e-07 453.72 1.42e-10 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.01436 on 4 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: 1
F-statistic: 2.059e+05 on 1 and 4 DF, p-value: 1.416e-10
plot7=ggplot(d7,aes(x=add,y=cps))+
geom_smooth(color='black', method='lm', formula=y ~ x, se=T,size=0.25)+geom_point(size = 1)+
scale_x_continuous(name=expression(paste("Ti concentration (mg k",g^-1,")")),
breaks = seq(0,20000,2500), limits = c(0, 20000))+
scale_y_continuous(name=expression(paste("Ti K",alpha," intensity (cps ",mu, "",A^-1,")")),breaks=seq(0,8,1), limits = c(0, 8))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.25),
axis.title.x = element_text(size = 14, color = "black"),
axis.title.y = element_text(size = 14, color = "black"),
axis.text.x = element_text(size = 12, angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 12, color = "black"))+
annotate(geom="text", y=2.8, x=14000,
label=expression(paste("y = 0.0003983x + 0.157")),size=5,color="black")+
annotate(geom="text", y=2.3, x=14000,label=expression(paste(R^2, " = 0.999")),size=5,color="black")+
annotate(geom="text", y=8, x=0,label="A",size=7,color="black")+
coord_fixed(ratio = 20000/8)
plot7
a=grid.arrange(plot7,plot6,ncol = 2)
ggsave("Plot feces curves.png", a, width = 10, height = 5, units = "in", dpi = 300)
d3=curvas[c(1:6),]
d3
m3=lm(cps~poly(add, degree = 2,raw=T),data=d3)
summary(m3)
Call:
lm(formula = cps ~ poly(add, degree = 2, raw = T), data = d3)
Residuals:
1 2 3 4 5 6
-0.30749 0.18157 0.53694 -0.47459 -0.07232 0.13590
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.075e-01 4.036e-01 0.762 0.501542
poly(add, degree = 2, raw = T)1 1.222e-03 5.864e-05 20.839 0.000242 ***
poly(add, degree = 2, raw = T)2 -1.171e-08 1.595e-09 -7.342 0.005222 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.4707 on 3 degrees of freedom
Multiple R-squared: 0.9989, Adjusted R-squared: 0.9982
F-statistic: 1389 on 2 and 3 DF, p-value: 3.542e-05
plot3=ggplot(d3,aes(x=add,y=cps))+
geom_smooth(color='black', method='lm', formula=y ~ poly(x,2), se=T, size=0.25)+geom_point(size = 1)+
scale_x_continuous(name=expression(paste("Cr concentration (mg k",g^-1,")")),
breaks = seq(0,40000,5000), limits = c(0, 40000))+
scale_y_continuous(name=expression(paste("Cr K",alpha," intensity (cps ",mu, "",A^-1,")")),breaks=seq(0,30,2), limits = c(0, 30))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.25),
axis.title.x = element_text(size = 14, color = "black"),
axis.title.y = element_text(size = 14, color = "black"),
axis.text.x = element_text(size = 12, angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 12, color = "black"))+
annotate(geom="text", y=8, x=26000,label=expression(paste("y = -0.0000000117",x^2," + 0.00122x + 0.3")),size=4,color="black")+
annotate(geom="text", y=6, x=26000,label=expression(paste(R^2, " = 0.999")),size=4,color="black")+
annotate(geom="text", y=30, x=0,label="A",size=7,color="black")+
coord_fixed(ratio = 40000/30)
plot3
d8=curvas[c(13:18),]
d8
m8=lm(cps~poly(add, degree = 2,raw=T),data=d8)
summary(m8)
Call:
lm(formula = cps ~ poly(add, degree = 2, raw = T), data = d8)
Residuals:
13 14 15 16 17 18
0.032042 -0.005871 0.030275 -0.147102 0.107113 -0.016456
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -3.204e-02 7.017e-02 -0.457 0.67896
poly(add, degree = 2, raw = T)1 8.984e-04 2.491e-05 36.061 4.69e-05 ***
poly(add, degree = 2, raw = T)2 -1.026e-08 1.300e-09 -7.891 0.00424 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.1086 on 3 degrees of freedom
Multiple R-squared: 0.9997, Adjusted R-squared: 0.9996
F-statistic: 5654 on 2 and 3 DF, p-value: 4.32e-06
plot8=ggplot(d8,aes(x=add,y=cps))+
geom_smooth(color='black', method='lm', formula=y ~ poly(x,2), se=T, size=0.25)+geom_point(size = 1)+
scale_x_continuous(name=expression(paste("Cr concentration (mg k",g^-1,")")),
breaks = seq(0,20000,2500), limits = c(0, 20000))+
scale_y_continuous(name=expression(paste("Cr K",alpha," intensity (cps ",mu, "",A^-1,")")),breaks=seq(0,14,2), limits = c(0, 14))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.25),
axis.title.x = element_text(size = 14, color = "black"),
axis.title.y = element_text(size = 14, color = "black"),
axis.text.x = element_text(size = 12, angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 12, color = "black"))+
annotate(geom="text", y=3.5, x=12500,label=expression(paste("y = -0.0000000103",x^2," + 0.00090x - 0.03")),size=4,color="black")+
annotate(geom="text", y=2.5, x=12500,label=expression(paste(R^2, " = 0.999")),size=4,color="black")+
annotate(geom="text", y=14, x=0,label="B",size=7,color="black")+
coord_fixed(ratio = 20000/14)
plot8
a=grid.arrange(plot3,plot8,ncol = 2)
ggsave("Plot polynomial.png", a, width = 10, height = 5, units = "in", dpi = 300)
d9=curvas[c(13:18),]
d9
m9=lm(cps.RhKaC~add,data=d9)
summary(m9)
Call:
lm(formula = cps.RhKaC ~ add, data = d9)
Residuals:
13 14 15 16 17 18
-0.05201 -0.02844 -0.01984 0.04912 0.12175 -0.07057
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.201e-02 4.380e-02 1.188 0.301
add 1.630e-04 4.977e-06 32.744 5.19e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.08082 on 4 degrees of freedom
Multiple R-squared: 0.9963, Adjusted R-squared: 0.9954
F-statistic: 1072 on 1 and 4 DF, p-value: 5.187e-06
plot9=ggplot(d9,aes(x=add,y=cps.RhKaC))+
geom_smooth(color='black', method='lm', formula=y ~ x, se=T, size=0.25)+geom_point(size = 1)+
scale_x_continuous(name=expression(paste("Cr concentration (mg k",g^-1,")")),
breaks = seq(0,20000,2500), limits = c(0, 20000))+
scale_y_continuous(name=expression(paste("Cr K",alpha," Rh K",alpha," ",Compton^-1,"")),breaks=seq(0,3.5,0.5), limits = c(0, 3.5))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.25),
axis.title.x = element_text(size = 14, color = "black"),
axis.title.y = element_text(size = 14, color = "black"),
axis.text.x = element_text(size = 12, angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 12, color = "black"))+
annotate(geom="text", y=1, x=15000,label=expression(paste("y = 0.000163x + 0.05")),size=5,color="black")+
annotate(geom="text", y=0.75, x=15000,label=expression(paste(R^2, " = 0.996")),size=5,color="black")+
annotate(geom="text", y=3.5, x=0,label="B",size=7,color="black")+
coord_fixed(ratio = 20000/3.5)
plot9
d10=curvas[c(19:24),]
d10
m10=lm(cps.RhKaC~add,data=d10)
summary(m10)
Call:
lm(formula = cps.RhKaC ~ add, data = d10)
Residuals:
19 20 21 22 23 24
0.001999 0.006018 -0.001838 0.003406 -0.017180 0.007595
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.030e-02 5.507e-03 5.502 0.00532 **
add 9.159e-05 6.174e-07 148.355 1.24e-08 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.0101 on 4 degrees of freedom
Multiple R-squared: 0.9998, Adjusted R-squared: 0.9998
F-statistic: 2.201e+04 on 1 and 4 DF, p-value: 1.238e-08
plot10=ggplot(d10,aes(x=add,y=cps.RhKaC))+
geom_smooth(color='black', method='lm', formula=y ~ x, se=T,size=0.25)+geom_point(size = 1)+
scale_x_continuous(name=expression(paste("Ti concentration (mg k",g^-1,")")),
breaks = seq(0,20000,2500), limits = c(0, 20000))+
scale_y_continuous(name=expression(paste("Ti K",alpha," Rh K",alpha," ",Compton^-1,"")),breaks=seq(0,2,0.25), limits = c(0, 2))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.25),
axis.title.x = element_text(size = 14, color = "black"),
axis.title.y = element_text(size = 14, color = "black"),
axis.text.x = element_text(size = 12, angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 12, color = "black"))+
annotate(geom="text", y=.6, x=14000,
label=expression(paste("y = 0.0000916x + 0.030")),size=5,color="black")+
annotate(geom="text", y=0.45, x=14000,label=expression(paste(R^2, " = 0.999")),size=5,color="black")+
annotate(geom="text", y=2, x=0,label="A",size=7,color="black")+
coord_fixed(ratio = 20000/2)
plot10
a=grid.arrange(plot10,plot9,ncol = 2)
ggsave("Plot feces compton.png", a, width = 10, height = 5, units = "in", dpi = 300)
EDXRF=read.csv("D:\\Armazenamento\\DATA R\\EDXRF\\edxrf.csv")
str(EDXRF)
'data.frame': 40 obs. of 6 variables:
$ marker : chr "Cr" "Cr" "Cr" "Cr" ...
$ spike : num 0.5 1 1.5 2 0.5 1 1.5 2 0.5 1 ...
$ sample : chr "FecesSheep" "FecesSheep" "FecesSheep" "FecesSheep" ...
$ observed : num 4846 9294 13849 18788 5922 ...
$ cps : num 3.98 7.53 10.09 13.27 6.5 ...
$ cps.RhKaC: num 0.925 1.711 2.396 3.102 1.488 ...
EDXRF$marker=as.factor(EDXRF$marker)
EDXRF$spike=as.factor(EDXRF$spike)
EDXRF$sample=as.factor(EDXRF$sample)
EDXRF
Cr equation
\(Y = (cps.RhKaC – 0.05) / 0.000163\)
data1=EDXRF[c(1:4),]
data1$predicted=(data1$cps.RhKaC-0.05)/0.000163
data1
mod1=lm(predicted~observed,data=data1)
summary(mod1)
Call:
lm(formula = predicted ~ observed, data = data1)
Residuals:
1 2 3 4
-269.9 307.5 170.7 -208.4
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.017e+03 4.272e+02 2.381 0.14025
observed 9.536e-01 3.339e-02 28.559 0.00122 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 346.4 on 2 degrees of freedom
Multiple R-squared: 0.9976, Adjusted R-squared: 0.9963
F-statistic: 815.6 on 1 and 2 DF, p-value: 0.001224
p1=ggplot(data1,aes(y=predicted,x=observed))+
geom_smooth(color='black', method=lm, se=T, size=0.5)+geom_point(size = 2)+
scale_y_continuous(name=expression(paste("Predicted Cr (mg k",g^-1,")")), breaks = seq(4000,20000,2000), limits = c(4000, 20000))+
scale_x_continuous(name=expression(paste("Added Cr (mg k",g^-1,")")), breaks=seq(4000,20000,2000), limits = c(4000, 20000))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.5),
axis.title.x = element_text(size = 16,color = "black"),
axis.title.y = element_text(size = 16,color = "black"),
axis.text.x = element_text(size = 15,angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 15,color = "black"))+
annotate(geom="text", y=10200, x=15000,label="Sheep feces",size=8,color="black")+
annotate(geom="text", y=8200, x=15000,label=expression(paste(y, " = 0.95x + 1000")),size=6,color="black")+
annotate(geom="text", y=7000, x=15000,label=expression(paste(R^2, " = 0.998")),size=6,color="black")+
annotate(geom="text", y=20000, x=4000,label="B",size=8,color="black")+
coord_fixed(ratio = 20000/20000)
p1
Ti equation
\(Y = (cps.RhKaC – 0.030 / 0.0000916\)
data2=EDXRF[c(21:24),]
data2$predicted=(data2$cps.RhKaC - 0.030) / 0.0000916
data2
mod2=lm(predicted~observed,data=data2)
summary(mod2)
Call:
lm(formula = predicted ~ observed, data = data2)
Residuals:
21 22 23 24
-21.45 17.75 25.15 -21.46
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.367e+02 3.776e+01 6.268 0.0245 *
observed 1.006e+00 2.929e-03 343.548 8.47e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 30.56 on 2 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: 1
F-statistic: 1.18e+05 on 1 and 2 DF, p-value: 8.473e-06
p2=ggplot(data2,aes(y=predicted,x=observed))+
geom_smooth(color='black', method=lm, se=T, size=0.5)+geom_point(size = 2)+
scale_y_continuous(name=expression(paste("Predicted Ti (mg k",g^-1,")")), breaks = seq(4000,20000,2000), limits = c(4000, 20000))+
scale_x_continuous(name=expression(paste("Added Ti (mg k",g^-1,")")), breaks=seq(4000,20000,2000), limits = c(4000, 20000))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.5),
axis.title.x = element_text(size = 16,color = "black"),
axis.title.y = element_text(size = 16,color = "black"),
axis.text.x = element_text(size = 15,angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 15,color = "black"))+
annotate(geom="text", y=10200, x=15000,label="Sheep feces",size=8,color="black")+
annotate(geom="text", y=8200, x=15000,label=expression(paste(y, " = 1.006x + 240")),size=6,color="black")+
annotate(geom="text", y=7000, x=15000,label=expression(paste(R^2, " = 0.999")),size=6,color="black")+
annotate(geom="text", y=20000, x=4000,label="A",size=8,color="black")+
coord_fixed(ratio = 20000/20000)
p2
Cr equation
\(Y = (cps.RhKaC – 0.05) / 0.000163\)
data3=EDXRF[c(5:8),]
data3$predicted=(data3$cps.RhKaC-0.05)/0.000163
data3
mod3=lm(predicted~observed,data=data3)
summary(mod3)
Call:
lm(formula = predicted ~ observed, data = data3)
Residuals:
5 6 7 8
257.9 -575.8 420.3 -102.4
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 412.32328 734.82402 0.561 0.63120
observed 1.37613 0.05585 24.638 0.00164 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 540.9 on 2 degrees of freedom
Multiple R-squared: 0.9967, Adjusted R-squared: 0.9951
F-statistic: 607 on 1 and 2 DF, p-value: 0.001643
p3=ggplot(data3,aes(y=predicted,x=observed))+
geom_smooth(color='black', method=lm, se=T, size=0.5)+geom_point(size = 2)+
scale_y_continuous(name=expression(paste("Predicted Cr (mg k",g^-1,")")), breaks = seq(4000,28000,2000), limits = c(4000, 28000))+
scale_x_continuous(name=expression(paste("Added Cr (mg k",g^-1,")")), breaks=seq(4000,28000,2000), limits = c(4000, 28000))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.5),
axis.title.x = element_text(size = 16,color = "black"),
axis.title.y = element_text(size = 16,color = "black"),
axis.text.x = element_text(size = 14,angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 14,color = "black"))+
annotate(geom="text", y=12000, x=20000,label="Cattle feces",size=8.5,color="black")+
annotate(geom="text", y=9000, x=20000,label=expression(paste(y, " = 1.38x + 400")),size=6,color="black")+
annotate(geom="text", y=7000, x=20000,label=expression(paste(R^2, " = 0.997")),size=6,color="black")+
annotate(geom="text", y=28000, x=4000,label="D",size=9,color="black")+
coord_fixed(ratio = 28000/28000)
p3
Ti equation
\(Y = (cps.RhKaC – 0.030 / 0.0000916\)
data4=EDXRF[c(25:28),]
data4$predicted=(data4$cps.RhKaC - 0.030) / 0.0000916
data4
mod4=lm(predicted~observed,data=data4)
summary(mod4)
Call:
lm(formula = predicted ~ observed, data = data4)
Residuals:
25 26 27 28
445.87 -705.19 11.49 247.82
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -453.53502 774.83805 -0.585 0.61757
observed 1.33236 0.06163 21.620 0.00213 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 615.5 on 2 degrees of freedom
Multiple R-squared: 0.9957, Adjusted R-squared: 0.9936
F-statistic: 467.4 on 1 and 2 DF, p-value: 0.002132
p4=ggplot(data4,aes(y=predicted,x=observed))+
geom_smooth(color='black', method=lm, se=T, size=0.5)+geom_point(size = 2)+
scale_y_continuous(name=expression(paste("Predicted Ti (mg k",g^-1,")")), breaks = seq(4000,28000,2000), limits = c(4000, 28000))+
scale_x_continuous(name=expression(paste("Added Ti (mg k",g^-1,")")), breaks=seq(4000,28000,2000), limits = c(4000, 28000))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.5),
axis.title.x = element_text(size = 16,color = "black"),
axis.title.y = element_text(size = 16,color = "black"),
axis.text.x = element_text(size = 14,angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 14,color = "black"))+
annotate(geom="text", y=12000, x=20000,label="Cattle feces",size=8.5,color="black")+
annotate(geom="text", y=9000, x=20000,label=expression(paste(y, " = 1.33x - 500")),size=6,color="black")+
annotate(geom="text", y=7000, x=20000,label=expression(paste(R^2, " = 0.996")),size=6,color="black")+
annotate(geom="text", y=28000, x=4000,label="C",size=9,color="black")+
coord_fixed(ratio = 28000/28000)
p4
Cr equation
\(Y = (cps.RhKaC – 0.052) / 0.000163\)
data5=EDXRF[c(9:12),]
data5$predicted=(data5$cps.RhKaC-0.05)/0.000163
data5
mod5=lm(predicted~observed,data=data5)
summary(mod5)
Call:
lm(formula = predicted ~ observed, data = data5)
Residuals:
9 10 11 12
95.42 -247.37 246.06 -94.10
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 728.4739 318.4581 2.288 0.14943
observed 1.2618 0.0246 51.304 0.00038 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 264.3 on 2 degrees of freedom
Multiple R-squared: 0.9992, Adjusted R-squared: 0.9989
F-statistic: 2632 on 1 and 2 DF, p-value: 0.0003797
p5=ggplot(data5,aes(y=predicted,x=observed))+
geom_smooth(color='black', method=lm, se=T, size=0.5)+geom_point(size = 2)+
scale_y_continuous(name=expression(paste("Predicted Cr (mg k",g^-1,")")), breaks = seq(4000,26000,2000), limits = c(4000, 26000))+
scale_x_continuous(name=expression(paste("Added Cr (mg k",g^-1,")")), breaks=seq(4000,26000,2000), limits = c(4000, 26000))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.5),
axis.title.x = element_text(size = 17,color = "black"),
axis.title.y = element_text(size = 17,color = "black"),
axis.text.x = element_text(size = 15,angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 15,color = "black"))+
annotate(geom="text", y=12000, x=19000,label="Horse feces",size=9,color="black")+
annotate(geom="text", y=9000, x=19000,label=expression(paste(y, " = 1.26x + 700")),size=7,color="black")+
annotate(geom="text", y=7000, x=19000,label=expression(paste(R^2, " = 0.999")),size=7,color="black")+
annotate(geom="text", y=26000, x=4000,label="F",size=10,color="black")+
coord_fixed(ratio = 26000/26000)
p5
Ti equation
\(Y = (cps.RhKaC – 0.030 / 0.0000916\)
data6=EDXRF[c(29:32),]
data6$predicted=(data6$cps.RhKaC - 0.030) / 0.0000916
data6
mod6=lm(predicted~observed,data=data6)
summary(mod6)
Call:
lm(formula = predicted ~ observed, data = data6)
Residuals:
29 30 31 32
509.78 -795.55 -24.58 310.35
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -551.28195 869.59414 -0.634 0.59095
observed 1.28156 0.06483 19.767 0.00255 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 703.5 on 2 degrees of freedom
Multiple R-squared: 0.9949, Adjusted R-squared: 0.9924
F-statistic: 390.7 on 1 and 2 DF, p-value: 0.002549
p6=ggplot(data6,aes(y=predicted,x=observed))+
geom_smooth(color='black', method=lm, se=T, size=0.5)+geom_point(size = 2)+
scale_y_continuous(name=expression(paste("Predicted Ti (mg k",g^-1,")")), breaks = seq(4000,26000,2000), limits = c(4000, 26000))+
scale_x_continuous(name=expression(paste("Added Ti (mg k",g^-1,")")), breaks=seq(4000,26000,2000), limits = c(4000, 26000))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.5),
axis.title.x = element_text(size = 17,color = "black"),
axis.title.y = element_text(size = 17,color = "black"),
axis.text.x = element_text(size = 15,angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 14,color = "black"))+
annotate(geom="text", y=12000, x=19000,label="Horse feces",size=9,color="black")+
annotate(geom="text", y=9000, x=19000,label=expression(paste(y, " = 1.28x - 600")),size=7,color="black")+
annotate(geom="text", y=7000, x=19000,label=expression(paste(R^2, " = 0.995")),size=7,color="black")+
annotate(geom="text", y=26000, x=4000,label="E",size=10,color="black")+
coord_fixed(ratio = 26000/26000)
p6
a = grid.arrange(p2, p1, p4, p3, p6, p5, ncol = 2, nrow = 3)
ggsave("Plots_feces_validation.png", a, width = 12, height = 18, units = "in", dpi = 300)
Ti equation
\(y = (cps.RhKaC + 0.06)/0.000131x\)
data7=EDXRF[c(33:36),]
data7$predicted=(data7$cps.RhKaC + 0.06) / 0.000131
data7
mod7=lm(predicted~observed,data=data7)
summary(mod7)
Call:
lm(formula = predicted ~ observed, data = data7)
Residuals:
33 34 35 36
55.58 44.64 -247.58 147.36
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 696.29438 258.73555 2.691 0.11479
observed 0.88105 0.03215 27.402 0.00133 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 209.9 on 2 degrees of freedom
Multiple R-squared: 0.9973, Adjusted R-squared: 0.996
F-statistic: 750.9 on 1 and 2 DF, p-value: 0.001329
p7=ggplot(data7,aes(y=predicted,x=observed))+
geom_smooth(color='black', method=lm, se=T, size=0.5)+geom_point(size = 2)+
scale_y_continuous(name=expression(paste("Predicted Ti (mg k",g^-1,")")), breaks = seq(2000,16000,2000), limits = c(2000, 16000))+
scale_x_continuous(name=expression(paste("Added Ti (mg k",g^-1,")")), breaks=seq(2000,16000,2000), limits = c(2000, 16000))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.5),
axis.title.x = element_text(size = 17,color = "black"),
axis.title.y = element_text(size = 17,color = "black"),
axis.text.x = element_text(size = 15,angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 15,color = "black"))+
annotate(geom="text", y=6400, x=11000,label="Concentrate",size=8,color="black")+
annotate(geom="text", y=5000, x=11000,label=expression(paste(y, " = 0.88x + 700")),size=6,color="black")+
annotate(geom="text", y=4000, x=11000,label=expression(paste(R^2, " = 0.997")),size=6,color="black")+
annotate(geom="text", y=16000, x=2000,label="A",size=10,color="black")+
coord_fixed(ratio = 16000/16000)
p7
Cr equation
\(Y = (cps.RhKaC – 0.30) / 0.000190\)
data8=EDXRF[c(13:16),]
data8$predicted=(data8$cps.RhKaC - 0.30) / 0.000190
data8
mod8=lm(predicted~observed,data=data8)
summary(mod8)
Call:
lm(formula = predicted ~ observed, data = data8)
Residuals:
13 14 15 16
-85.84 219.33 -170.79 37.30
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -346.87008 255.69438 -1.357 0.307751
observed 1.08933 0.02786 39.098 0.000654 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 207.4 on 2 degrees of freedom
Multiple R-squared: 0.9987, Adjusted R-squared: 0.998
F-statistic: 1529 on 1 and 2 DF, p-value: 0.0006535
p8=ggplot(data8,aes(y=predicted,x=observed))+
geom_smooth(color='black', method=lm, se=T, size=0.5)+geom_point(size = 2)+
scale_y_continuous(name=expression(paste("Predicted Cr (mg k",g^-1,")")), breaks = seq(2000,16000,2000), limits = c(2000, 16000))+
scale_x_continuous(name=expression(paste("Added Cr (mg k",g^-1,")")), breaks=seq(2000,16000,2000), limits = c(2000, 16000))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.5),
axis.title.x = element_text(size = 17,color = "black"),
axis.title.y = element_text(size = 17,color = "black"),
axis.text.x = element_text(size = 15,angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 15,color = "black"))+
annotate(geom="text", y=6400, x=11000,label="Concentrate",size=8,color="black")+
annotate(geom="text", y=5000, x=11000,label=expression(paste(y, " = 1.09x - 300")),size=6,color="black")+
annotate(geom="text", y=4000, x=11000,label=expression(paste(R^2, " = 0.999")),size=6,color="black")+
annotate(geom="text", y=16000, x=2000,label="B",size=10,color="black")+
coord_fixed(ratio = 16000/16000)
p8
Ti equation
\(y = (cps.RhKaC + 0.06)/0.000131x\)
data9=EDXRF[c(37:40),]
data9$predicted=(data9$cps.RhKaC + 0.06) / 0.000131
data9
mod9=lm(predicted~observed,data=data9)
summary(mod9)
Call:
lm(formula = predicted ~ observed, data = data9)
Residuals:
37 38 39 40
-144.722 212.371 8.349 -75.998
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 838.02560 234.32862 3.576 0.07007 .
observed 0.75494 0.02915 25.898 0.00149 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 189.6 on 2 degrees of freedom
Multiple R-squared: 0.997, Adjusted R-squared: 0.9955
F-statistic: 670.7 on 1 and 2 DF, p-value: 0.001488
p9=ggplot(data9,aes(y=predicted,x=observed))+
geom_smooth(color='black', method=lm, se=T, size=0.5)+geom_point(size = 2)+
scale_y_continuous(name=expression(paste("Predicted Ti (mg k",g^-1,")")), breaks = seq(2000,14000,2000), limits = c(2000, 14000))+
scale_x_continuous(name=expression(paste("Added Ti (mg k",g^-1,")")), breaks=seq(2000,14000,2000), limits = c(2000, 14000))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.5),
axis.title.x = element_text(size = 17,color = "black"),
axis.title.y = element_text(size = 17,color = "black"),
axis.text.x = element_text(size = 15,angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 15,color = "black"))+
annotate(geom="text", y=5300, x=10000,label="Mineral salt",size=8,color="black")+
annotate(geom="text", y=4000, x=10000,label=expression(paste(y, " = 0.75x + 800")),size=6,color="black")+
annotate(geom="text", y=3000, x=10000,label=expression(paste(R^2, " = 0.991")),size=6,color="black")+
annotate(geom="text", y=14000, x=2000,label="C",size=10,color="black")+
coord_fixed(ratio = 14000/14000)
p9
Cr equation
\(Y = (cps.RhKaC – 0.30) / 0.000190\)
data10=EDXRF[c(17:20),]
data10$predicted=(data10$cps.RhKaC - 0.30) / 0.000190
data10
mod10=lm(predicted~observed,data=data10)
summary(mod10)
Call:
lm(formula = predicted ~ observed, data = data10)
Residuals:
17 18 19 20
-156.0 178.3 121.2 -143.4
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -382.6079 264.2009 -1.448 0.284555
observed 0.9827 0.0287 34.236 0.000852 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 213.8 on 2 degrees of freedom
Multiple R-squared: 0.9983, Adjusted R-squared: 0.9974
F-statistic: 1172 on 1 and 2 DF, p-value: 0.0008521
p10=ggplot(data10,aes(y=predicted,x=observed))+
geom_smooth(color='black', method=lm, se=T, size=0.5)+geom_point(size = 2)+
scale_y_continuous(name=expression(paste("Predicted Cr (mg k",g^-1,")")), breaks = seq(2000,14000,2000), limits = c(2000, 14000))+
scale_x_continuous(name=expression(paste("Added Cr (mg k",g^-1,")")), breaks=seq(2000,14000,2000), limits = c(2000, 14000))+
theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
axis.ticks = element_line(colour = "black", size = 0.5),
axis.title.x = element_text(size = 17,color = "black"),
axis.title.y = element_text(size = 17,color = "black"),
axis.text.x = element_text(size = 15,angle = 25, hjust = 1, color = "black"),
axis.text.y = element_text(size = 15,color = "black"))+
annotate(geom="text", y=5300, x=10000,label="Mineral salt",size=8,color="black")+
annotate(geom="text", y=4000, x=10000,label=expression(paste(y, " = 0.98x - 400")),size=6,color="black")+
annotate(geom="text", y=3000, x=10000,label=expression(paste(R^2, " = 0.998")),size=6,color="black")+
annotate(geom="text", y=14000, x=2000,label="D",size=10,color="black")+
coord_fixed(ratio = 14000/14000)
p10
a = grid.arrange(p7, p8, p9, p10, ncol = 2, nrow = 2)
ggsave("Plots_hay_validation.png", a, width = 12, height = 12, units = "in", dpi = 300)
EDXRF1 =rbind(data1,data2, data3, data4, data5, data6, data7, data8, data9, data10)
EDXRF1$recovery=(EDXRF1$predicted/EDXRF1$observed)*100
EDXRF1
summary = EDXRF1 %>%
group_by(sample, marker) %>%
summarise(
sd = sd(recovery, na.rm = TRUE),
recovery = mean(recovery))
`summarise()` has grouped output by 'sample'. You can override using the `.groups` argument.
summary
#Plot
g1=ggplot(summary[c(3:8),], aes(x=sample, y=recovery, fill=marker))+
geom_col(position = "dodge")+
geom_errorbar(aes(ymin=recovery-sd, ymax=recovery+sd), width=.2, position=position_dodge(.9))+
geom_hline(yintercept=100, linetype="dashed", color = "blue")+
geom_hline(yintercept=110, linetype="dashed", color = "red")+
geom_hline(yintercept=90, linetype="dashed", color = "red")+
scale_fill_manual(values = c("grey40","grey80"),name= "Markers")+
scale_y_continuous(name="Recovery (%)", breaks = seq(0,160,10), limits = c(0, 160))+
scale_x_discrete(name="", labels=c("FecesCattle" = "Cattle feces","FecesHorse" = "Horse feces",
"FecesSheep" = "Sheep feces"))
g1
g2=g1+theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
legend.background = element_rect(fill = "transparent", size=0.5, linetype="solid",colour ="black"),
legend.position = c(0.50, 0.95),legend.key.size = unit(0.42, 'cm'),
legend.direction="horizontal",
axis.ticks = element_line(colour = "black", size = 1),
legend.text = element_text(size = 23),
legend.title = element_text(size = 23),
axis.title.y = element_text(size = 21, color = "black"),
axis.text.x = element_text(size = 21, angle = 10, hjust = 1, color = "black"),
axis.text.y = element_text(size = 19, color = "black"))+
annotate(geom="text", y=160, x=0.5,label="A",size=11,color="black")
g2
#Plot
g3=ggplot(summary[c(1:2,9:10),], aes(x=sample, y=recovery, fill=marker))+
geom_col(position = "dodge")+
geom_errorbar(aes(ymin=recovery-sd, ymax=recovery+sd), width=.2, position=position_dodge(.9))+
geom_hline(yintercept=100, linetype="dashed", color = "blue")+
geom_hline(yintercept=110, linetype="dashed", color = "red")+
geom_hline(yintercept=90, linetype="dashed", color = "red")+
scale_fill_manual(values = c("grey40","grey80"),name= "Markers")+
scale_y_continuous(name="Recovery (%)", breaks = seq(0,130,10), limits = c(0, 130))+
scale_x_discrete(name="", labels=c("Concentrate+Hay" = "Concentrate","Salt+Hay" = "Mineral salt"))
g3
g4=g3+theme(axis.line = element_line(colour = "black", size = 0.5, linetype = "solid"),
panel.background = element_rect(fill = "transparent"),
legend.background = element_rect(fill = "transparent", size=0.5, linetype="solid",colour ="black"),
legend.position = c(0.50, 0.95),legend.key.size = unit(0.42, 'cm'),
legend.direction="horizontal",
axis.ticks = element_line(colour = "black", size = 1),
legend.text = element_text(size = 23),
legend.title = element_text(size = 23),
axis.title.y = element_text(size = 21, color = "black"),
axis.text.x = element_text(size = 21, angle = 10, hjust = 1, color = "black"),
axis.text.y = element_text(size = 19, color = "black"))+
annotate(geom="text", y=130, x=0.5,label="B",size=11,color="black")
g4
a = grid.arrange(g2, g4, ncol = 1, nrow = 2)
ggsave("Plot_recovery.png", a, width = 10, height = 12, units = "in", dpi = 300)