setna.pt: Set values to 'NA' for potato data.

View source: R/setna_pt.R

setna.ptR Documentation

Set values to NA for potato data.

Description

Detect impossible values for potato data and set them to missing value (NA) according to some rules.

Usage

setna.pt(dfr, f = 10)

Arguments

dfr

The name of the data frame.

f

Factor for extreme values detection. See details.

Details

The data frame must use the labels (lower or upper case) listed in function check.names.pt. Consider the following groups of traits:

  • pre (traits evaluated pre-harvest): ppe, plant_unif, plant_vigor and se.

  • cnn (continuos non-negative traits): tntpl, nmtpl, ttwp, ttwpl, mtwp, mtwpl, nomtwp, mtwci, mtwcii, ttya, ttyna, mtya, and mtyna.

  • cpo (continuous positive traits): atw, atmw, fwts1, fwts2, dwts1, and dwts2.

  • pnn (percentage non-negative traits): ppe, pph, fruc, gluc, sucr, and malt.

  • ppo (percentage positive traits): dm, pro, star, and fiber.

  • dnn (discrete non-negative traits): ntp, npe, nph, tntp, nmtp, nnomtp, nmtci, and nmtcii.

  • ctg (categorical 1 to 9 traits): plant_unif, plant_vigor, se, tuber_apper, tub_unif, tub_size, num_stolon, and leng_stolon.

Values are set to NA with the following rules:

  • cnn traits with negative values are set to NA.

  • cpo traits with non-positive values are set to NA.

  • pnn traits with values out of the [0, 100] interval are set to NA.

  • ppo with values out of the (0, 100] interval are set to NA.

  • dnn traits with negative and non-integer values are set to NA.

  • ctg traits with out of scale values are set to NA.

  • Extreme low and high values are detected using the interquartile range. The rule is to detect any value out of the interval [Q_1 - f \times (m/3 + IQR); Q_3 + f \times (m/3 + IQR)] where m is the mean. By default f = 10 and if less than 10 a warning is shown. Values out of this range are set to NA.

  • If npe == 0 and there is some data for any trait, then npe is set to NA.

  • If nph == 0 and there is some data for any non-pre-harvest trait, then nph is set to NA.

  • If nmtp == 0 and mtwp > 0, then nmtp is set to NA.

  • If nmtp > 0 and mtwp == 0, then mtwp is set to NA.

  • If nnomtp == 0 and nomtwp > 0, then nnomtp is set to NA.

  • If nnomtp > 0 and nomtwp == 0, then nomtwp is set to NA.

Value

It returns the data frame with all impossible values set to NA and a list of warnings with all the rows that have been modified.

Author(s)

Raul Eyzaguirre.

Examples

dfr <- data.frame(mtwp = c(2.2, 5.0, 3.6, 12, 1600, -4, 0),
                  dm = c(21, 23, 105, 24, -3, 30, NA),
                  nmtp = c(1.3, 10, 11, NA, 2, 5, NA))
setna.pt(dfr)

reyzaguirre/st4gi documentation built on April 30, 2024, 5:45 a.m.