as.data.frame: Create data frame

Description Usage Arguments Details Value See Also Examples

Description

These as.data.frame methods create a data frame from aggregated and discretised values in a manner distinct from extract. flatten converts into a ‘flat’ data frame, including all measurements in a single column (suitable, e.g., for lattice).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  ## S4 method for signature 'MOPMX'
as.data.frame(x, row.names = NULL,
    optional = FALSE, sep = "_", csv.data = TRUE, settings = TRUE,
    include = FALSE, ..., stringsAsFactors = default.stringsAsFactors()) 
  ## S4 method for signature 'OPM'
as.data.frame(x, row.names = NULL,
    optional = FALSE, sep = "_", csv.data = TRUE, settings = TRUE,
    include = FALSE, ..., stringsAsFactors = default.stringsAsFactors()) 
  ## S4 method for signature 'OPMA'
as.data.frame(x, row.names = NULL,
    optional = FALSE, sep = "_", csv.data = TRUE, settings = TRUE,
    include = FALSE, ..., stringsAsFactors = default.stringsAsFactors()) 
  ## S4 method for signature 'OPMD'
as.data.frame(x, row.names = NULL,
    optional = FALSE, sep = "_", csv.data = TRUE, settings = TRUE,
    include = FALSE, ..., stringsAsFactors = default.stringsAsFactors()) 
  ## S4 method for signature 'OPMS'
as.data.frame(x, row.names = NULL,
    optional = FALSE, sep = "_", csv.data = TRUE, settings = TRUE,
    include = FALSE, ..., stringsAsFactors = default.stringsAsFactors()) 
  ## S4 method for signature 'kegg_compound'
as.data.frame(x, row.names = NULL,
    optional = TRUE, ..., stringsAsFactors = FALSE) 
  ## S4 method for signature 'kegg_compounds'
as.data.frame(x, row.names = NULL,
    optional = TRUE, ..., stringsAsFactors = FALSE) 

  ## S4 method for signature 'MOPMX'
flatten(object, include = NULL, fixed = list(),
    factors = FALSE, ...) 
  ## S4 method for signature 'OPM'
flatten(object, include = NULL, fixed = list(),
    factors = TRUE, exact = TRUE, strict = TRUE, full = TRUE,
    numbers = FALSE, ...) 
  ## S4 method for signature 'OPMS'
flatten(object, include = NULL, fixed = list(), ...)

Arguments

x

Object of class OPM, its child classes, or OPMS or MOPMX. If an OPMS object, for the as.data.frame method its elements must either all be OPM or all be OPMA or all be OPMD objects. If a MOPMX object, its elements must be conforming OPMS or either OPM, OPMA or OPMS objects.

There are as.data.frame methods for some of the objects created by substrate_info, too.

row.names

Optional vector for use as row names of the resulting data frame. Here, it is not recommended to try to set row names explicitly.

optional

Logical scalar passed to the list and matrix methods of as.data.frame.

sep

Character scalar used as word separator in column names. Set this to NULL or an empty vector to turn off character replacement in column names.

csv.data

Logical scalar indicating whether the csv_data entries that identify the plate shall be included.

settings

Logical scalar indicating whether the aggr_settings and disc_settings entries, if available, shall be included.

stringsAsFactors

Logical scalar passed to the list and matrix methods of as.data.frame.

object

OPM or OPMS object (or list).

include

For flatten, either NULL, character vector, list or formula. If not empty, include this meta-information in the data frame, replicated in each row. Otherwise it converted to a list and passed to metadata. See there for details.

For as.data.frame, if empty or FALSE, ignored. If TRUE, all metadata are included using to_metadata. If otherwise and non-empty, metadata selected using extract_columns are included.

fixed

NULL or list. If not NULL, include these items in the data frame, replicated in each row.

factors

Logical scalar. See the stringsAsFactors argument of data.frame and as.data.frame from the base package.

exact

Logical scalar. Passed to metadata.

strict

Logical scalar. Passed to metadata.

full

Logical scalar. Replace well coordinates by full names?

numbers

Logical scalar. Use numbers instead of well names? This is not recommended for must usages.

...

Optional other arguments passed to wells, or from the OPMS to the OPM method, or to the list and matrix methods of as.data.frame.

Details

The as.data.frame methods for OPMX objects are mainly intended to produce objects that can easily be written to CSV files, for instance using write.table from the utils package. There are no opm methods other than batch_opm (which can write such files) that make use of the created kind of objects. In particular, they cannot be input again into opm.

The following entries are contained in the generated data frame:

The limits of using CSV as output format already show up in this list, and in general we recommend to generate YAML or JSON output instead.

For the as.data.frame methods of the other classes, see substrate_info.

In the data frame returned by flatten, column names are unchecked (not converted to variable names). The three last columns are coding for time, well and value, with the exact spelling of the column names given by param_names.

The OPMS method yields an additional column for the plate, the exact spelling of its name also being available via param_names. This column contains the position of each plate within object.

The MOPMX method yields a another additional column for the plate type. There is currently no safeguard against having several OPMX objects of the same plate type within a MOPMX object.

Value

The as.data.frame methods create a data frame with one row for each combination of well and plate.

The flatten methods create a data frame with one row for each combination of time point, well and plate.

See Also

utils::write.table stats::reshape pkgutils::flatten

Other conversion-functions: extract, extract_columns, merge, oapply, opmx, plates, rep, rev, sort, split, to_yaml, unique

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## OPMD method of as.data.frame()
summary(x <- as.data.frame(vaas_1))
stopifnot(is.data.frame(x), nrow(x) == 96)

## OPMS method of as.data.frame()
summary(x <- as.data.frame(vaas_4[, , 1:10]))
stopifnot(is.data.frame(x), nrow(x) == 10 * 4)

## OPM method of flatten()
# distinct numbers of columns due to distinct selection settings
head(x <- flatten(vaas_1))
stopifnot(is.data.frame(x), identical(dim(x), c(36864L, 3L)))
head(x <- flatten(vaas_1, fixed = "TEST", include = "Strain"))
stopifnot(is.data.frame(x), identical(dim(x), c(36864L, 5L)))

## OPMS method of flatten()
# distinct numbers of columns due to distinct selection settings
head(x <- flatten(vaas_4[, , 1:10]))
stopifnot(is.data.frame(x), identical(dim(x), c(15360L, 4L)))
head(x <- flatten(vaas_4[, , 1:10], fixed = "TEST", include = ~ Strain))
stopifnot(is.data.frame(x), identical(dim(x), c(15360L, 6L)))

opm documentation built on May 2, 2019, 6:08 p.m.