d <- c(0.05, 0.10, 0.20, 0.40, 0.6, 0.7, 0.8, 0.84)
s <- c(0.012, 0.028, 0.05, 0.1, 0.15, 0.176, 0.8,9)
sd <- data.frame("x"=1/s, "y"=1/d)
fit <- lm(y~x, data = sd)
ggReg <- function (fit) {
require(ggplot2)
ggplot(fit$model, aes_string(x = names(fit$model)[2], y = names(fit$model)[1])) +
geom_point(alpha = 0.5, size =5) +
stat_smooth(method = "lm", se = TRUE, fill = NA) +
labs(title = paste("Adj R2 = ",signif(summary(fit)$adj.r.squared, 5),
"Intercept =",signif(fit$coef[[1]],5 ),
" Slope =",signif(fit$coef[[2]], 5),
" P =",signif(summary(fit)$coef[2,4], 5))) +
theme(axis.title.y = element_text(size = rel(1.8), angle = 90))+
theme(axis.title.x = element_text(size = rel(1.8), angle = 00)) +
theme(plot.title = element_text(lineheight=3, face="bold", color="black", size=20))
}
ggReg(fit) +
labs(x = "1/S", y = "1/D")
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.2.3

t <- c(0,2,4,8,10,12,14,16,18)
x <- c(0.2,0.211,0.305, 0.98,1.77,3.2,5.6,6.15,6.2)
lnx <- log(x)
s <- c(9.23,9.21,9.07,8.03,6.8,4.6,0.92,0.077,0)
tx <- data.frame("x"=t, "y"=lnx)
ggplot(tx, aes(x,y)) +
geom_point(alpha = 0.5, size = 5) +
geom_line() +
labs(x = "t, h", y = "lnX, g/L")
