Skip to contents

Functions for extracting and adding metadata for objects of class TD.

getMeta extracts a data.frame with location, date, design, latitude, longitude, plot width and plot length 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).



setMeta(TD, meta)



An object of class TD.


A data.frame containing metadata.


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:


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


The date of the trial.


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.


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


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


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


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()



## Create a TD object.
dropsTD <- createTD(data = dropsRaw[dropsRaw$year == 2012, ],
                    genotype = "Variety_ID",
                    trial = "Experiment",
                    loc = "Site",
                    repId = "Replicate",
                    subBlock = "block",
                    rowCoord = "Row",
                    colCoord = "Column",
                    trLat = "Lat",
                    trLong = "Long")

## Get meta data from dropsTD.
(dropsMeta <- getMeta(dropsTD))
#>        trLocation trDate trDesign  trLat trLong trPlWidth trPlLength
#> Cam12R Campagnola   <NA>       NA 45.171  9.532        NA         NA
#> Cra12R    Craiova   <NA>       NA 44.116 24.348        NA         NA
#> Gai12W    Gaillac   <NA>       NA 43.910  1.890        NA         NA
#> Kar12W  Karlsruhe   <NA>       NA 49.100  8.320        NA         NA
#> Ner12R      Nerac   <NA>       NA 44.170  0.307        NA         NA

## Add trial date to meta data.
dropsMeta$trDate <- as.Date(rep("010112", times = 5), "%d%m%y")

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