alter_whatever: Alter data within a 'BGF'

View source: R/alter_functions.R

alter_whateverR Documentation

Alter data within a BGF

Description

A set of functions that allow to alter data in each layer of a BGF.

Usage

alter_whatever(x, layer, what, value, ID = NULL, feedback = FALSE)

alter_BG_measurement(
  x,
  reactor_id,
  time_id,
  col,
  measurement,
  ID = NULL,
  feedback = FALSE
)

Arguments

x

a BGF

layer

a character referring a layer of a BGF; either 'ExpParam' or 'metaData'

what

a character referring either to a list entry of the ExpParam layer, or a column of the metaData layer of a BGF

value, measurement

either a character, numeric or logic. The desired new value

ID

defaults to NULL, for alter_whatever can be a character or integer referring to row names in the metaData layer is. For alter_BG_measurement it can be an integer referring to a row in the BioGasData layer of a BGF

feedback

logic, if TRUE the function will print a feedback to the R console

reactor_id

a character identifying a the reactor/ fermentation whose entry in BioGasData needs to be changed

time_id

a numeric specifying the time that has passed since fermentation start for the chosen reactor

col

a character specifying the name of the column of the BioGasData layer that needs to be changed

Details

The two functions alter_whatever and alter_BG_measurement can be used to change information in each layer of a BGF. The function alter_whatever can be used to change data in the ExpParam or metaData layer.

The function alter_BG_measurement changes a single entry in the BioGasData layer of the BGF. This entry can be selected by providing the name of the reactor for which a measurement should be changed, together with the time after fermentation start when the measurement was acquired. Alternatively, the row number in the BioGasData layer of that measurement can be provided to 'ID'.

Value

a BGF

Examples

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

# change name to 'newName'
myBGF <- alter_whatever(myBGF,"ExpParam","name","newName",feedback=TRUE)

# exclude reactor 5,6 and 7
myBGF <- alter_whatever(myBGF,"metaData","Excluded",TRUE,c("R5","R6","R7"),feedback=TRUE)

# exclude all reactors
myBGF <- alter_whatever(myBGF,"metaData","Excluded",TRUE)

# change the 'product' column of reactor 1 at time 0 to 7777
myBGF <- alter_BG_measurement(myBGF,"R1",0,"production",7777)

#  do the same for reactor 2 but index via 'ID'
myBGF <- alter_BG_measurement(myBGF,ID=2,col="production",measurement=7777)


bgfanalyzer documentation built on Sept. 26, 2026, 5:07 p.m.