%q% {opm}R Documentation

Query metadata

Description

Search for the presence of metadata values for given keys, either using a vector, factor, list, formula, expression or WMD object.

Usage

  ## S4 method for signature 'ANY,MOPMX'
x %Q% table 
  ## S4 method for signature 'MOPMX,ANY'
x %Q% table 
  ## S4 method for signature 'MOPMX,MOPMX'
x %Q% table 
  ## S4 method for signature 'MOPMX,WMD'
x %Q% table 
  ## S4 method for signature 'MOPMX,WMDS'
x %Q% table 
  ## S4 method for signature 'WMD,ANY'
x %Q% table 
  ## S4 method for signature 'WMD,MOPMX'
x %Q% table 
  ## S4 method for signature 'WMD,WMD'
x %Q% table 
  ## S4 method for signature 'WMD,WMDS'
x %Q% table 
  ## S4 method for signature 'WMDS,ANY'
x %Q% table 
  ## S4 method for signature 'WMDS,MOPMX'
x %Q% table 
  ## S4 method for signature 'character,WMD'
x %Q% table 
  ## S4 method for signature 'character,WMDS'
x %Q% table 
  ## S4 method for signature 'expression,WMD'
x %Q% table 
  ## S4 method for signature 'expression,WMDS'
x %Q% table 
  ## S4 method for signature 'factor,WMD'
x %Q% table 
  ## S4 method for signature 'factor,WMDS'
x %Q% table 
  ## S4 method for signature 'formula,WMD'
x %Q% table 
  ## S4 method for signature 'formula,WMDS'
x %Q% table 
  ## S4 method for signature 'list,WMD'
x %Q% table 
  ## S4 method for signature 'list,WMDS'
x %Q% table 

  ## S4 method for signature 'ANY,MOPMX'
x %q% table 
  ## S4 method for signature 'MOPMX,ANY'
x %q% table 
  ## S4 method for signature 'MOPMX,MOPMX'
x %q% table 
  ## S4 method for signature 'MOPMX,WMD'
x %q% table 
  ## S4 method for signature 'MOPMX,WMDS'
x %q% table 
  ## S4 method for signature 'WMD,ANY'
x %q% table 
  ## S4 method for signature 'WMD,MOPMX'
x %q% table 
  ## S4 method for signature 'WMD,WMD'
x %q% table 
  ## S4 method for signature 'WMD,WMDS'
x %q% table 
  ## S4 method for signature 'WMDS,ANY'
x %q% table 
  ## S4 method for signature 'WMDS,MOPMX'
x %q% table 
  ## S4 method for signature 'character,WMD'
x %q% table 
  ## S4 method for signature 'character,WMDS'
x %q% table 
  ## S4 method for signature 'expression,WMD'
x %q% table 
  ## S4 method for signature 'expression,WMDS'
x %q% table 
  ## S4 method for signature 'factor,WMD'
x %q% table 
  ## S4 method for signature 'factor,WMDS'
x %q% table 
  ## S4 method for signature 'formula,WMD'
x %q% table 
  ## S4 method for signature 'formula,WMDS'
x %q% table 
  ## S4 method for signature 'list,WMD'
x %q% table 
  ## S4 method for signature 'list,WMDS'
x %q% table 

Arguments

x

Character vector, factor, list, formula, expression or WMD object used as query. See ‘Details’. x and table can swap their places.

table

WMD, WMDS or MOPMX object. x and table can swap their places.

Details

The behaviour of these methods depends on the object used as query. infix.largeq is usually stricter than infix.q, sometimes equivalent.

See subset for usage examples with OPMS objects.

Value

Logical vector of the length of the WMD or WMDS object. For MOPMX objects, a list of such vectors.

Examples

# The data set vaas_1 contains the metadata keys 'Species' and 'Experiment'
# with the values 'Escherichia coli' and 'First replicate'.

## Character methods

stopifnot(!"Experiment" %q% vaas_1) # wrong query here; compare to %k%
stopifnot(!"First replicate" %q% vaas_1) # again wrong query
stopifnot(c(Experiment = "First replicate") %q% vaas_1) # correct query
stopifnot(c(Experiment = "First replicate") %Q% vaas_1)

stopifnot(!"Species" %q% vaas_1) # wrong query
stopifnot(!"Escherichia coli" %q% vaas_1) # wrong query
stopifnot(c(Species = "Escherichia coli") %q% vaas_1) # correct query

# This does not work because the value has the wrong type
stopifnot(!c(`Plate number` = "6") %Q% vaas_1)
# Compare to %q%
stopifnot(c(`Plate number` = "6") %q% vaas_1)

stopifnot(c(Species = "Escherichia coli",
  Experiment = "First replicate") %q% vaas_1) # combined query, all TRUE
stopifnot(c(Species = "Escherichia coli",
  Experiment = "First replicate") %Q% vaas_1) # all present

stopifnot(character() %q% vaas_1) # empty query always results
stopifnot(character() %Q% vaas_1)

## List methods

stopifnot(list(Experiment = "First replicate") %q% vaas_1)
stopifnot(list(Experiment = "First replicate") %Q% vaas_1) # present

# Choice among alternatives
stopifnot(list(Experiment = c("First replicate",
  "Second replicate")) %q% vaas_1) # one of them TRUE
stopifnot(!list(Experiment = c("Second replicate",
  "Third replicate")) %q% vaas_1) # none of them TRUE

# Combined query together with choice among alternatives
stopifnot(list(Experiment = c("First replicate", "Second replicate"),
  Species = c("Escherichia coli", "Bacillus subtilis")) %q% vaas_1)

# Choice among alternatives is not done here: this query fails unless this
# two-element vector is contained. Compare to %q%.
stopifnot(!list(Experiment = c("First replicate",
  "Second replicate")) %Q% vaas_1)

stopifnot(list() %q% vaas_1) # empty query always results
stopifnot(list() %Q% vaas_1)

stopifnot(vaas_1 %q% vaas_1) # obviously
stopifnot(vaas_1 %Q% vaas_1)

## Formulae for querying

stopifnot((~ Experiment == "First replicate") %q% vaas_1)
stopifnot((~ Experiment == "First replicate") %Q% vaas_1)
stopifnot(vaas_1 %q% ~ Experiment == "First replicate")
stopifnot(vaas_1 %Q% ~ Experiment == "First replicate")
stopifnot(vaas_1 %q% ~ Species == "Escherichia coli")
stopifnot(vaas_1 %Q% ~ Species == "Escherichia coli")
stopifnot(vaas_1 %q% ~ Species != "Bacillus subtilis")
stopifnot(vaas_1 %Q% ~ Species != "Bacillus subtilis")

x <- try(vaas_1 %q% ~ missing.name == "abc", silent = TRUE) # fails
stopifnot(inherits(x, "try-error"))
x <- try(vaas_1 %Q% ~ missing.name == "abc", silent = TRUE) # also fails
stopifnot(inherits(x, "try-error"))
missing.name <- "abc"  # enclosing environment considered or ignored
stopifnot(vaas_1 %q% ~ missing.name == "abc")
x <- try(vaas_1 %Q% ~ missing.name == "abc", silent = TRUE) # still fails
stopifnot(inherits(x, "try-error"))
rm(missing.name) # tidy up

# examples for OPMS methods are given under subset()

[Package opm version 1.3.63 Index]