Skip to contents

Imports observed mass flow rates stored in a *.csv file and then organizes the data for use with the BMB function.

Usage

importObservations(file, header = TRUE, csv.params = NULL)

Arguments

file

Character string containing the name of *.csv from file which data will be read. See Details below for valid file structures.

header

Logical indicating if the first row of file file contains header information. Current implementation of importObservations discards this information.

csv.params

List of arguments to be passed to read.csv

Value

Returns a list of data frames. Each data frame is named according to the unique sample components specified in the second column of file. This list object is intended to be used as the argument y for the BMB function.

Details

The purpose of this function is to make it easy to import and structure loosely organized data contained in a *.csv into a list for use as the y argument passed to the BMB function. The entries in file must be organized as such:

  • The first column of file must contain an integer sample location. The value of this integer must correspond to the column number used to specify linear constraints in constrainProcess. For example, data for a given component collected at sampling location \(y_2\) should be indicated with a 2 in the first column of file used with importObservations. In the file used with constrainProcess, the linear constraint(s) on \(y_2\) are indicated in the second column.

  • The second column of file must contain sample component names. This field is case sensitive. Ensure a given sample component is named consistently, including capitalization and spacing.

  • Columns 3 to \(K+2\) of file must contain observed mass flow rates for the \(K\) collected sample sets. All observations located in the same column should be collected at the same time.

  • Sample components of interest must be specified for each location. If a sample component is not detected at some locations, but is detected at others, this component should be included in file with a specified mass flow rate of 0, or a very small number.

importObservations reads the contents of file, sorts the sampling locations numerically, then creates a list of data frames. Each data frame contains the data for a single sample component.

Examples


 y <- importObservations(file = system.file("extdata", "twonode_example.csv",
                                      package = "BayesMassBal"),
                   header = TRUE, csv.params = list(sep = ";"))

## The linear constraints for this example data set are:
C <- matrix(c(1,-1,0,-1,0,0,1,-1,0,-1), byrow = TRUE, ncol = 5, nrow = 2)

## The X matrix for this data set can be found using:
X <- constrainProcess(C = C)