Learn R Programming

biogas (version 1.0.1)

summBg: Summarize and Normalize Cumulative Methane Production

Description

From cumulative gas production, used summBg standardize, interpolate, subtract innoculum contribution, normalize by substrate mass, and summarize the output calculating mean and standard devations for each type of sample (groups of replicates). The function is flexible so all or only one operation can be done when called. Typically summBg is handy to get the biochemical methane potential (BMP) from cumulative methane production.

Usage

summBg(vol, setup, id.name="id", time.name="time", descrip.name="descrip", 
       inoc.name=NULL, norm.name=NULL, inoc.m.name="minoc", vol.name="cvCH4", 
       imethod="linear", extrap=FALSE, when=30, show.obs=FALSE)

Arguments

vol
a data frame with the columns reactor identification code; time of measurement (as numeric, or POSIX); and the respomse variable biogas volume or cumulative volume. The names of these columns can be specified with id.n
setup
a data frame containing information to summarize, substract inoculum effect or normalize the data. Should contain at least the column id.name (reactor identification code), and the additional columns depending on the operations desired. See '
id.name
name of the reactor identification code column in vol and setup. Should be the same in all data frames used in the function. Default is "id".
time.name
name of column containing time data in vol. Default is "time".
descrip.name
(optional) name of column containing a description of reactor substrate (or a code for this) in setup data frame. The summary of the data will be made following this column. Default is "descrip".
inoc.name
(optional) the value in the descrip.name (setup data frame) column that is used to describe the inoculum-only reactors. Length one character vector. Argument not used by default.
norm.name
(optional) the name of the column in setup that has the mass to perform the normalizartion (typically substrate mass). Length one character vector. Argument not used by default.
inoc.m.name
(optional) the name of the column in setup that has inoculum mass. Length one character vector. Default is "minoc".
vol.name
the name of the column in vol that contains the response variable --typically cumulative methane volume. The default is "cvCH4" for cumulative volume of methane (CH4).
imethod
the interpolation method to be used. This is passed as the method argument to interp. Length one character vector. Default is "linear" for linear interpolation.
extrap
should extrapolation be carried out? Set to TRUE if extrapolation wanted. Length one logical vector. This is passed as the extrap argument to interp. Default is FALS
when
value(s) of time.name in vol data frame at which the results should be evaluated. Numeric vector. Alternatively, set to "end" to return the latest values for each reactor.
show.obs
set to TRUE to return all observations, otherwise means and standard deviations are returned. Default is FALSE.

Value

  • a data frame, with the colums:
  • descripfrom the input data frames
  • meanmean of the response variable vol.name
  • sdstandard deviation of the response variable vol.name
  • nnumber of reactors

concept

biogas

Details

summBg was primarily designed to calculate the biochemical methane potential (BMP) from cumulative methane production of a set of batch reactors through these steps: interpolation of cumulative production to a specified time (if needed), subtratction of apparent innoculum contribution, normalization of the results by substrate mass (typically volatile solids (VS) mass, but could be the mass of anything within the reactor) and calculation of mean and standard deviation for each sample type (set of replicates, identified by descrip.name). If needed summBg can return values for all observations and be used for simpler operations e.g., determining cumulative biogas production at some specified time or normalizing gas volume by different substrate characteristics. To summarize data setup data frame should have a column with a description of reactor substrate (or a code for this). Its name is set by descrip.name. If the inoculum effect is to be subtracted out, a column named descrip.name (for identifying replicates) and a column with the mass of inoculum present (any units), with a name set by inoc.m.name are both required in setup. To normalize by substrate mass (or any mass to be used for normalization), an additional column with the mass of substrate is needed in setup --its name is set by norm.name. This function is probably easiest to understand by example. See 'Examples'.

See Also

cumBg

Examples

Run this code
data("vol")
data("comp") 
data("setup") 
# First need to calculate cumulative methane production data
cprod <- cumBg(vol,temp=20,comp=comp,time.name="days",extrap=TRUE)
head(cprod)
 
# Cumulative methane production at 30 d
summBg(vol=cprod,setup=setup,when=30,time.name="days")

# Or total cumulative biogas
summBg(vol=cprod,setup=setup,when=30,time.name="days",vol.name="cvBg")

# Cumulative CH4 only, subtract inoculum contribution
summBg(vol=cprod,setup=setup,when=30,time.name="days",inoc.name="inoc")

# And normalize by sub.vs column (mass of substrate VS here) (so the result is BMP)
summBg(vol=cprod,setup=setup,when=30,time.name="days",inoc.name="inoc",norm.name="msub")

# Same example, but return results for three times
summBg(vol=cprod,setup=setup,when=c(10,30,60),time.name="days",inoc.name="inoc",
       norm.name="msub")

# Back to earlier example, but return all individual observations (and total production
# and individual contributions of substrate and inoculum 
summBg(vol=cprod,setup=setup,when=30,time.name="days",inoc.name="inoc",norm.name="msub",
       show.obs=TRUE)

# Something different: interpolated biogas production rates
summBg(vol=cprod,setup=setup,when=30,time.name="days",vol.name="rvBg",show.obs=TRUE)
 
# Example with dataset with different column names
data("vol2")
data("comp2")
data("setup2")

# First need to calculate cumulative methane production data
cprod <- cumBg(vol2,temp=20,comp=comp2,id.name="bottle",time.name="days",dat.name="meas.vol",
               comp.name="CH4.conc",extrap=TRUE)
head(cprod)
 
# Cumulative CH4 production at 30 d, subtract inoculum contribution and normalize by sub.vs column 
# (mass of substrate VS here)
summBg(vol=cprod,setup=setup2,when=30,id.name="bottle",time.name="days",descrip.name="description",
       inoc.name="Inoculum",inoc.m.name="inoc.mass",norm.name="sub.vs")

Run the code above in your browser using DataLab