statgenSTA (version 1.0.2)

getMeta: Get and set metadata for TD objects

Description

Functions for extracting and adding metadata for objects of class TD. getMeta extracts a data.frame with location, date, design, latitude, longitude, plotWidth and plotLength for all trials in TD. setMeta adds metadata from a data.frame to an object of class TD. See details for the specifications of the data.frame. The most common use case is extracting metadata from a TD object, modifying the content and then adding it back to the TD object. Information in the metadata of a TD object is used in plotting functions (e.g. latitude and longitude for a map plot) and when fitting models on the data (the trial design).

Usage

getMeta(TD)

setMeta(TD, meta)

Arguments

TD

An object of class TD.

meta

A data.frame containing metadata.

Details

When setting metadata, metadata has to be a data.frame with rownames corresponding to the trials in TD. The data.frame should contain one or more of the following columns:

trLocation

The location of the trial. Used as default name when creating plots and summaries.

trDate

The date of the trial.

trDesign

The design of the trial. One of "none" (no (known) design), "ibd" (incomplete-block design), "res.ibd" (resolvable incomplete-block design), "rcbd" (randomized complete block design), "rowcol" (row-column design) or "res.rowcol" (resolvable row-column design). Used when fitting models.

trLat

The latitude of the trial on a scale of -90 to 90. Used when plotting the trials on a map.

trLong

The longitude of the trial on a scale of -180 to 180. Used when plotting the trials on a map.

trPlWidth

The width of the plot. Used in combination with trPlLength to determine the size of the plots in a layout plot of a trial.

trPlLength

The length of the plot. Used in combination with trPlWidth to determine the size of the plots in a layout plot of a trial.

The values of the metadata of TD will be set to the values in the corresponding column in meta. Existing values will be overwritten, but NA will be ignored so setting a value to NA won't result in accidentally removing it.

See Also

Other functions for TD objects: TD, plot.TD(), summary.TD()

Examples

Run this code
# NOT RUN {
data("wheatChl")

## Create a TD object.
wheatTD <- createTD(data = wheatChl, genotype = "trt", repId = "rep",
                    subBlock = "bl", rowCoord = "row", colCoord = "col")

## Get meta data from wheatTD
(wheatMeta <- getMeta(wheatTD))

## Add location names and latitude/longitude to meta data.
wheatMeta$trLocation <- c("Cauquenes", rep("Santa Rosa", times = 4))
wheatMeta$trLat <- c(-35.58, rep(-36.32, times = 4))
wheatMeta$trLong <- c(-72.17, rep(-71.55, times = 4))

## Add back meta data to wheatTD.
wheatTD <- setMeta(wheatTD, wheatMeta)

# }

Run the code above in your browser using DataCamp Workspace