Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fit_many

Fitting many functions across groups


Description

Fitting many functions across groups

Usage

fit_many(data, funct, group, ...)

Arguments

data

Dataframe

funct

Function to fit

group

Grouping variables

...

Arguments for the function to fit. Use ?functionname to read the help file on available arguments for a given function.

Value

fit_many fits a function across every instance of a grouping variable.

Examples

# 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 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
)

photosynthesis

Tools for Plant Ecophysiology & Modeling

v2.0.0
MIT + file LICENSE
Authors
Joseph Stinziano [aut] (<https://orcid.org/0000-0002-7628-4201>), Cassaundra Roback [aut], Demi Gamble [aut], Bridget Murphy [aut], Patrick Hudson [aut, dtc], Chris Muir [aut, cre] (<https://orcid.org/0000-0003-2555-3878>)
Initial release
2020-09-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.