get.data: Access data in "obkData" objects

Description Usage Arguments Author(s) Examples

Description

get.data is a generic function with a method for obkData objects. It can be used to retrieve various information, known only by the name of the field looked for.

Usage

1
2
3
4
5
get.data(x, ...)

## S4 method for signature 'obkData'
get.data(x, data, where=NULL, drop=TRUE,
       showSource=FALSE, ...)

Arguments

x

an obkData object.

data

a character string indicating the name of the data field to look for.

where

an optional character string indicating the name of the slot in which the information should be looked for; if NULL, the method will look in all slots starting with @individuals, then @samples, and finally in @records.

drop

a logical indicating if a vector should be returned (TRUE), as opposed to a data.frame with on single column (FALSE).

showSource

a logical indicating if information about individualIDs and slot sources should be returned. If TRUE a dataframe with three columns will be returned, as opposed to a vector/single column if FALSE.

...

currently not used.

Author(s)

Thibaut Jombart, Lulla Opatowski

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## LOAD DATA ##
data(ToyOutbreak)
ls()


## VARIOUS USE OF GET.DATA ##
# list all the data with name 'Sex' from the obkData object
get.data(ToyOutbreak, "Sex")

# list all the data with 'date' from the obkData object
get.data(ToyOutbreak, "date")
get.data(ToyOutbreak, "date", showSource=TRUE)
get.data(ToyOutbreak, "date", where="records")

# Extract from the obkData object a given field
x <- get.data(ToyOutbreak, "records")
names(x) # x contains the whole 'records' list
head(x$Fever)
x <- get.data(ToyOutbreak, "samples")
names(x) # x contains the whole 'samples' data.frame

OutbreakTools documentation built on Oct. 6, 2017, 1:03 a.m.