#################Example 1#################
#Using only required arguments
#Creating a data.frame.
#First, columns containing independent variable.
#Second, columns containing dependent variable.
#The data frame created presents two
#fermentation curves for two yeasts with
#different times and carbon dioxide production.
df <- data.frame('Time_Yeast_A' = seq(0,280, by=6.23),
'Time_Yeast_B' = seq(0,170, by=3.7777778),
'CO2_Production_Yeast_A' = c(0,0.97,4.04,9.62,13.44,17.50,
24.03,27.46,33.75,36.40,40.80,
44.24,48.01,50.85,54.85,57.51,
61.73,65.43,66.50,72.41,75.47,
77.22,78.49,79.26,80.31,81.04,
81.89,82.28,82.56,83.13,83.62,
84.11,84.47,85.02,85.31,85.61,
86.05,86.27,85.29,86.81,86.94,
87.13,87.33,87.45,87.85),
'CO2_Production_Yeast_B' = c(0,0.41,0.70,3.05,15.61,18.41,
21.37,23.23,28.28,41.28,43.98,
49.54,54.43,60.40,63.75,69.29,
76.54,78.38,80.91,83.72,84.66,
85.39,85.81,86.92,87.38,87.61,
88.38,88.57,88.72,88.82,89.22,
89.32,89.52,89.71,89.92,90.11,
90.31,90.50,90.70,90.90,91.09,
91.29,91.49,91.68,91.88))
#Using the plot_fit function to
#generate elegants graphs PDF files
#containing both observed data and
#predicted data.
#Graph plotted only with Model 5PL
#fit (models = 1)
plot_fit(data = df,
models = 1,
startA = 0,
startB = 1.5,
startC = 500,
startD = 92,
startG = 1500)
#Graph plotted with 5PL and Gompertz
#model fits (models = 4)
plot_fit(data = df,
models = 4,
startA = 0,
startB = 1.5,
startC = 500,
startD = 92,
startG = 1500)
#################Example 2#################
#Using the various function arguments to
#customize the graph.
#Creating a data.frame.
#First, columns containing independent variable.
#Second, columns containing dependent variable.
#The data frame created presents two
#fermentation curves for two yeasts with
#different times and carbon dioxide production.
df <- data.frame('Time_Treatment_A' = seq(0,200, by=6.45),
'Time_Treatment_B' = seq(0,200, by=6.45),
'CO2_Production_Treatment_A' = c(0,0.47,0.78,3.23,19.15,22.86,
26.81,29.36,36.14,52.61,55.58,
61.38,66.25,71.83,74.8,78.88,
83.47,84.48,85.94,87.45,87.98,
88.42,88.68,89.40,89.72,89.87,
90.41,90.51,90.62,90.70,91.05,
91.185),
'CO2_Production_Treatment_B' = c(0,0.19,0.39,1.36,9.23,11.29,
13.58,15.06,19.34,30.92,33.28,
37.98,42.14,47.17,50.00,54.28,
60.92,62.80,65.54,69.74,71.52,
73.07,73.98,76.75,77.79,78.70,
80.65,81.48,82.07,82.47,84.04,
84.60))
#Using the plot_fit function to
#generate elegants graphs PDF files
#containing both observed data and
#predicted data.
#Graph plotted only with Model 5PL
#fit (models = 1)
#Do not show R^2
plot_fit(data = df,
startA = 0,
startB = 1.5,
startC = 500,
startD = 92,
startG = 1500,
models = 1,
col = "red", #Color of observed data (points)
col1 = "blue", #Predicted data color from model 1 (line). Model = 1 <- 5PL Model
axisX = "Fermentation time (h)", #Title X-Axis
axisY = "Carbon dioxide production (g/L)", #Title Y-Axis
breaksX = seq(0,200,20), #X-Axis scale (positions). 0,20,40,60,80,...
limitsX = c(0,200), #X-Axis Limits
breaksY = seq(0,90,5),#Y-Axis scale (positions). 0,5,10,15,20,...
limitsY = c(0,95), #Y-Axis Limits
font = "serif",
font.size = 12,
legend.position = "right",
show.R2 = FALSE) #Do not show R^2
#Graph plotted with 5PL and 4PL
#model fits (models = 5)
#Show R^2
if (FALSE) {
plot_fit(data = df,
models = 5,
startA = 0,
startB = 1.5,
startC = 500,
startD = 92,
startG = 1500,
col = "#000000", #Color of observed data (points)
col1 = "#FF0000", #Predicted data color from model 1 (line). Model = 1 <- 5PL Model
col3 = "#0B6121",#Predicted data color from model 3 (line). Model = 3 <- 4PL Model
axisX = "Time (h)", #Title X-Axis
axisY = "CO2 production (g/L)", #Title Y-Axis
breaksX = seq(0,200,20), #X-Axis scale (positions). 0,20,40,60,80,...
limitsX = c(0,200), #X-Axis Limits
breaksY = seq(0,90,10),#Y-Axis scale (positions). 0,10,20,30,40,...
limitsY = c(0,95), #Y-Axis Limits
font = "serif",
font.size = 14,
legend.position = "bottom",
show.R2 = TRUE) #Show R^2
}
#Graph plotted with 5PL, Gompertz and 4PL
#model fits (models = 7)
#Do not show R^2
if (FALSE) {
plot_fit(data = df,
models = 7,
startA = 0,
startB = 1.5,
startC = 500,
startD = 92,
startG = 1500,
col = "#FF0000", #Color of observed data (points)
col1 = "#FF00FF", #Predicted data color from model 1 (line). Model = 1 <- 5PL Model
col2 = "#0101DF",#Predicted data color from model 2 (line). Model = 2 <- Gompertz Model
col3 = "#088A08",#Predicted data color from model 3 (line). Model = 3 <- 4PL Model
axisX = "Time (h)", #Title X-Axis
axisY = "Carbon dioxide production (g/L)", #Title Y-Axis
breaksX = seq(0,200,20), #X-Axis scale (positions). 0,20,40,60,80,...
limitsX = c(0,200), #X-Axis Limits
breaksY = seq(0,90,10),#Y-Axis scale (positions). 0,10,20,30,40,...
limitsY = c(0,95), #Y-Axis Limits
font = "serif",
font.size = 14,
legend.position = "top",
show.R2 = FALSE) #Do not show R^2
}
Run the code above in your browser using DataLab