TD | R Documentation |
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:
Check input data
Rename columns to default column names - default column names: genotype, trial, loc, year, repId, subBlock, rowCoord, colCoord, rowId, colId, checkId
Convert column types to default column types - rowCoord and colCoord are converted to numeric columns, all other renamed columns to factor columns. Columns other than the default columns, e.g. traits or other covariates will be included in the output unchanged.
Split input data by trial - each trial in the input data will become a list item in the output.
Add meta data - the trial meta data are added as attributes to the
different output items. The function parameters starting with "tr" provide
the meta data. Their values will be recycled if needed, so by setting a
single "trDesign", all trials will get the same design. For trLat, trLong,
trDesign and trDate a column in data
that contains the information
can be specified as well. The meta data can be changed later on using
getMeta
and setMeta
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.
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)
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
|
trial |
An optional character string indicating the column in
|
loc |
An optional character string indicating the column in
|
year |
An optional character string indicating the column in |
repId |
An optional character string indicating the column in
|
subBlock |
An optional character string indicating the column in
|
plotId |
An optional character string indicating the column in
|
rowCoord |
An optional character string indicating the column in
|
colCoord |
An optional character string indicating the column in
|
rowId |
An optional character string indicating the column in
|
colId |
An optional character string indicating the column in
|
checkId |
An optional character string indicating the column in
|
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
|
trDesign |
An optional character string indicating the column in
|
trLat |
An optional character string indicating the column in |
trLong |
An optional character string indicating the column in
|
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. |
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.
Other functions for TD objects:
getMeta()
,
plot.TD()
,
summary.TD()
## 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.