TD {statgenSTA}R Documentation

S3 class TD

Description

createTD
Function for creating objects of S3 class TD (Trial Data). The function converts a data.frame to an object of class TD in the following steps:

addTD
Function for adding extra trial data to an existing object of class TD. The data for the new trials will be added after the data for existing trials. It is possible to add data for an already existing trial, but this will cause multiple items in the output with identical names, which might cause problems later on in the analysis. Therefore a warning will be issued in this case.

dropTD
Function for removing data for selected trials from an existing object of class TD.

summary.TD and plot.TD methods are available.

Usage

createTD(
  data,
  genotype = NULL,
  trial = NULL,
  loc = NULL,
  year = NULL,
  repId = NULL,
  subBlock = NULL,
  plotId = NULL,
  rowCoord = NULL,
  colCoord = NULL,
  rowId = rowCoord,
  colId = colCoord,
  checkId = NULL,
  trLocation = NULL,
  trDate = NULL,
  trDesign = NULL,
  trLat = NULL,
  trLong = NULL,
  trPlWidth = NULL,
  trPlLength = NULL
)

addTD(
  TD,
  data,
  genotype = NULL,
  trial = NULL,
  loc = NULL,
  year = NULL,
  repId = NULL,
  subBlock = NULL,
  plotId = NULL,
  rowCoord = NULL,
  colCoord = NULL,
  rowId = rowCoord,
  colId = colCoord,
  checkId = NULL,
  trLocation = NULL,
  trDate = NULL,
  trDesign = NULL,
  trLat = NULL,
  trLong = NULL,
  trPlWidth = NULL,
  trPlLength = NULL
)

dropTD(TD, rmTrials)

Arguments

data

A data.frame containing trial data with at least a column for genotype. The data.frame should be in a wide format, i.e. all available phenotypic data should be in a separate column within the data.frame.

genotype

An optional character string indicating the column in data that contains genotypes.

trial

An optional character string indicating the column in data that contains trials.

loc

An optional character string indicating the column in data that contains trial locations.

year

An optional character string indicating the column in data that contains years.

repId

An optional character string indicating the column in data that contains replicates.

subBlock

An optional character string indicating the column in data that contains sub blocks.

plotId

An optional character string indicating the column in data that contains plots. This column will be combined with trial to a single output factor.

rowCoord

An optional character string indicating the column in data that contains the row coordinates.

colCoord

An optional character string indicating the column in data that contains the column coordinates.

rowId

An optional character string indicating the column in data that contains field rows. If not supplied, this is assumed to be the same as rowCoord.

colId

An optional character string indicating the column in data that contains field columns. If not supplied, this is assumed to be the same as colCoord.

checkId

An optional character string indicating the column in data that contains the check IDs.

trLocation

An optional character vector indicating the locations of the trials. This will be used as default names when creating plots and summaries. If no locations are provided, first the column loc is considered. If this contains one unique value for a trial this is used as trLocation. Otherwise the trial name is used.

trDate

An optional character string indicating the column in data that contains the date of the trial or a date vector indicating the dates of the trials.

trDesign

An optional character string indicating the column in data that contains the design of the trial or a character vector indicating the designs of the trials. Either "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).

trLat

An optional character string indicating the column in data that contains the latitude of the trial or a numerical vector indicating the latitudes of the trials on a scale of -90 to 90.

trLong

An optional character string indicating the column in data that contains the latitude of the trial or a numerical vector indicating the longitudes of the trials on a scale of -180 to 180.

trPlWidth

An optional positive numerical vector indicating the widths of the plots.

trPlLength

An optional positive numerical vector indicating the lengths of the plots.

TD

An object of class TD which should be modified.

rmTrials

A character vector of trials that should be removed.

Value

An object of class TD, a list of data.frames with renamed columns and an attribute renamedCols containing an overview of renamed columns. For each unique value of trial, the output has a data.frame in the list with the same name as the trial. These data.frames have attributes containing the metadata for the corresponding trial. If there is no column for trial, the list will contain one item named after the input data.

See Also

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

Examples

## Create a data.frame to be converted to TD object.
## The data consists of genotype, trial, row and column information and
## two traits, yield and flowering time.
datT1 <- data.frame(geno = paste0("G", 1:10),
                    tr = "T1",
                    row = rep(1:5, each = 2),
                    col = rep(1:2, times = 5),
                    yield = 1:10,
                    flowering = 3:12)

## Convert data.frame to TD object.
TDT1 <- createTD(data = datT1,
                 genotype = "geno",
                 trial = "tr",
                 rowCoord = "row",
                 colCoord = "col")

## Create a second data.frame similar to the first with data for a second trial.
datT2 <- data.frame(geno = paste0("G", 1:10),
                    tr = "T2",
                    row = rep(1:2, each = 5),
                    col = rep(1:5, times = 2),
                    yield = 10:1,
                    flowering = 12:3)

## Add this data to the TD object created above.
TDTot <- addTD(TD = TDT1,
               data = datT2,
               genotype = "geno",
               trial = "tr",
               rowCoord = "row",
               colCoord = "col")

## Drop the data for the first trial from the object.
TDT2 <- dropTD(TD = TDTot,
               rmTrials = "T1")


[Package statgenSTA version 1.0.13 Index]