View source: R/missing_values.R
| close_gaps | R Documentation |
Two functions exist, that can be used to close gaps in the BioGasData layer of a BGF.
Depending on the function, used either the last valid value of a fermentation is carried forward or values in between two measurements can be interpolated.
close_gaps(x, feedback = FALSE)
na_correction(x, which = "all_num", ...)
x |
a |
feedback |
|
which |
either a |
... |
further arguments passed to bgf_interpolation |
The function close_gaps can be used to quickly close gaps at the end of a series of fermentations.
It will go through each 'time' in the BioGasData layer of a BGF and check if the corresponding 'product' and 'production' values are NA.
If TRUE the respective previous value will be selected and replaces the NA.
This action will be done specifically for each 'reactor' level.
It is called by from_AMPTSV2_report when creating a BGF from an AMPTS II generated report.
The function na_correction can be used to close gaps in between or at the end of a fermentation.
Target data columns can be specified as integer or character in the which argument.
Alternatively, which can be 'all_num' (the default) to select all numeric columns in the BioGasData-layer of a BGF.
Internally the function calls bgf_interpolation on each column specified via the which argument.
Additional arguments passed to na_correction will be forwarded to bgf_interpolation as well.
a BGF
# create an example BGF
myBGF <- BGF(
ReactorLayout = c("2*Meso","Cellulose","2*S1 ctrl","2*S1 7d","2*S1 4d",
"2*S2 ctrl","2*S2 4d","2*S2 6d"),
BlankLabel = "Meso",
name = "myBGF",
ProcessTemp = 42,
MeasurementType = "AMPTSV2")
# add data generated by an AMPTS II
myBGF <- add_bmp_measurement(
x = myBGF,
path = base::system.file("extdata","AMPTSV2.csv",package = "bgfanalyzer"))
# convert data columns
myBGF <- cols_to_numeric(myBGF)
# close gaps in data
myBGF <- close_gaps(myBGF)
# another example BGF
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 gas quality measurements
gasq <- 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 gas quality data to BGF
myBGF2 <- add_BG_parameter(
x = myBGF2,
parameter = gasq,
reactor= "R1",
time = 3,
value = 2,
name = "H2",
cut_zero = TRUE,
interpolate_missing = FALSE)
# ensure data structure integrity (recommended before using na_correction)
myBGF2 <- update_BGF(myBGF2)
# close gaps resulting from merging fermentation data and gas quality data
# in all numerics of the BGF's 'BioGasData'-layer
myBGF2 <- na_correction(x=myBGF2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.