# \donttest{
# Read in your data
# Note that this data is coming from data supplied by the package
# hence the complicated argument in read.csv()
# This dataset is a CO2 by light response curve for a single sunflower
data <- read.csv(system.file("extdata", "A_Ci_Q_data_1.csv",
package = "photosynthesis"
))
# Define a grouping factor based on light intensity to split the ACi
# curves
data$Q_2 <- as.factor((round(data$Qin, digits = 0)))
# Convert leaf temperature to K
data$T_leaf <- data$Tleaf + 273.15
# Fit ACi curve. Note that we are subsetting the dataframe
# here to fit for a single value of Q_2
fit <- fit_aci_response(data[data$Q_2 == 1500, ],
varnames = list(
A_net = "A",
T_leaf = "T_leaf",
C_i = "Ci",
PPFD = "Qin"
)
)
# View fitted parameters
fit[[1]]
# View graph
fit[[2]]
# View data with modelled parameters attached
fit[[3]]
# Fit many curves
fits <- fit_many(
data = data,
varnames = list(
A_net = "A",
T_leaf = "T_leaf",
C_i = "Ci",
PPFD = "Qin"
),
funct = fit_aci_response,
group = "Q_2"
)
# Print the parameters
# First set of double parentheses selects an individual group value
# Second set selects an element of the sublist
fits[[3]][[1]]
# Print the graph
fits[[3]][[2]]
# Compile graphs into a list for plotting
fits_graphs <- compile_data(fits,
list_element = 2
)
# Compile parameters into dataframe for analysis
fits_pars <- compile_data(fits,
output_type = "dataframe",
list_element = 1
)
# }
Run the code above in your browser using DataLab