View source: R/add_functions.R
| add_whatever | R Documentation |
BGFA set of functions to add data to each layer of a BGF.
add_whatever(x, layer, what, lab = "newData", feedback = FALSE)
add_ExpParam(x, what, feedback = FALSE)
add_metaData(x, what, makeCol = TRUE, lab = "newData", feedback = FALSE)
add_BG_measurement(x, reactor, time, col, measurement, feedback = FALSE)
add_BG_parameter(
x,
parameter,
reactor,
time = NULL,
value = NULL,
name = NULL,
makeCol = TRUE,
cut_zero = TRUE,
interpolate_missing = TRUE,
default_start = 0
)
x |
a |
layer |
a |
what |
a |
lab |
a |
feedback |
|
makeCol |
|
reactor |
a |
time |
for |
col |
either a |
measurement |
a |
parameter |
either a |
value |
defaults is |
name |
defaults is |
cut_zero |
|
interpolate_missing |
|
default_start |
a |
There are five functions that can be useful to add data to BGF.
The first is add_whatever, which allows to add data either to the ExpParam or the metaData layer of a BGF.
The functions add_ExpParam and add_metaData are wrapper functions that internally call add_whatever with the 'layer'
For add_ExpParam argument 'what' is expected to be a named vector of length 1.
The name of the vector will be kept as label of a list entry in the ExpParam layer and the vectors value will be the value of that list entry.
For add_metaData argument 'what' is expected vector of the same length as number of rows in the metaData layer.
It will copy that vector to the metaData layer as a new column.
That column can be named using the 'lab' argument.
Otherwise a standard name is created.
The function checks if the chosen name already exists in metaData and will eventually generate a new name.
The function add_BG_measurement adds a single measurement value to an existing column of the BioGasData layer.
To this end the user must specify to which reactor of the BGF the measurement belongs to (argument 'reactor') and at which time the measurement was taken (argument 'time').
The argument 'col' is the name or position of the column in the BioGasData layer to which the measurement should be added.
The function add_BG_parameter allows to add a new data column to the BioGasData layer of a BGF.
It is very useful if not all measurements for a fermentation can be imported from the same standard record, e.g. if exhaust gas volumes are measured by one device, while the gas composition is registered by another.
a BGF
# create an example BGF
myBGF <- from_AMPTSV2_report(
ReactorLayout = c("2*Blank","Cellulose","3*neg ctrl","3*FR1","3*FR2","3*FR3"),
BlankLabel = "Blank",
name = "Test",
InocToSubRatio=2,
ProcessTemp = 52,
path = base::system.file("extdata","AMPTSV2.csv",package = "bgfanalyzer")
)
# add a start date to 'ExpParam'
myBGF <- add_whatever(myBGF,"ExpParam",what = c("Start date"="2026-05-04 12:00:00"))
# add organic total solutes measurements to 'metaData'
myBGF <- add_whatever(
x = myBGF,
layer = "metaData",
what = c("oTS"=c(2.3,2.3,98.8,4.5,4.4,4.6,3.5,3.6,3.5,3.8,3.9,4,3.5,3.6,3.8))
)
# add a end date to 'ExpParam'
myBGF<-add_ExpParam(x = myBGF,what = c("End date"="2026-06-04 12:00:00"))
# add total solutes measurement to 'metaData'
myBGF<-add_metaData(
x = myBGF,
what = c(3.3,3.3,99.8,6.5,6.6,6.6,6.5,6.6,6.5,6.8,6.9,6,6.5,6.6,6.8),
lab="TS")
# add a new 'product' gas measurement for reactor 'R1' at time '49' (days) after fermentation start
myBGF<-add_BG_measurement(x = myBGF,reactor = "R1",time = 49,col = "product",measurement = 7777)
# create a second example BGF from a standard record with exhaust gas data
myBGF2<-from_standard_record(
ReactorLayout = "A",
ProcessTemp = 80,
InocToSubRatio = .1,
path = base::system.file("extdata","Fermentation_A.tsv",package = "bgfanalyzer"),
time_col = 1,
product_col = 3)
# import another standard record that provides additional information on the 'BioGasData' layer
Gas_comp<-import_standard_record(
ipath = base::system.file(
"extdata",
"gasq_A.tsv",
package = "bgfanalyzer"
),
mkFRTime = "2025-01-15 17:00:00",
FRTime_col = 1,
units = "hours")
# add the gas composition data to the BGF and interpolate missing values
myBGF2<-add_BG_parameter(
x = myBGF2,
parameter = Gas_comp,
reactor = "R1",
time = 3,
value = 2,
name = "H2",
cut_zero = TRUE,
interpolate_missing = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.