setzero | R Documentation |
0
for potato and sweetpotato data.Set values to 0
for variables at harvest.
setzero(dfr, crop = c("auto", "pt", "sp", "uk"), checknames = FALSE)
dfr |
The name of the data frame. |
crop |
|
checknames |
Logical indicating if column names should be checked, default |
This function sets values to 0
for all variables at harvest
according to some rules.
For potato, variables (nph
, nmtp
, nnomtp
, mtwp
,
and nomtwp
) which are NA
according to the following rules:
If npe > 0
and nph == 0
, then all variables are set to 0
.
If nmtp == 0
, then mtwp
is set to 0
.
If mtwp == 0
, then nmtp
is set to 0
.
If nnomtp == 0
, then nomtwp
is set to 0
.
If nomtwp == 0
, then nnomtp
is set to 0
.
For sweetpotato, variables (noph
, nopr
, vw
, nocr
,
nonc
, crw
, and ncrw
) which are NA
according to
the following rules:
If nope > 0
and noph == 0
, then all variables are set to 0
.
If all variables are 0
, then noph
is set to 0
.
If nopr == 0
, then all variables with exception of vw
are set to 0
.
If all variables with exception of vw
are 0
, then
nopr
is set to 0
.
If nocr == 0
, then crw
is set to 0
.
If crw == 0
, then nocr
is set to 0
.
If nonc == 0
, then ncrw
is set to 0
.
If ncrw == 0
, then nonc
is set to 0
.
It returns a data frame and a list of warnings with all the rows that have been modified.
Raul Eyzaguirre
dfr <- data.frame(nph = c(NA, 0, 3, 3, 3, 3, 3),
mtwp = c(NA, NA, NA, NA, 8, 2, 0),
nomtwp = c(NA, NA, NA, 2, NA, 2, 4),
nmtp = c(NA, NA, NA, 0, 6, 2, 0),
nnomtp = c(NA, NA, NA, 4, 0, 3, 5))
setzero(dfr)
dfr <- data.frame(noph = c(NA, 0, 3, 3, 3, 3, 3),
nopr = c(NA, 0, 0, 2, 3, 3, 3),
vw = c(NA, NA, 3, 2, 3, 3, 6),
crw = c(NA, NA, NA, NA, 8, 2, 0),
ncrw = c(NA, NA, NA, 2, NA, 2, 4),
nocr = c(NA, NA, NA, 0, 6, 2, 0),
nonc = c(NA, NA, NA, 4, 0, 3, 5))
setzero(dfr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.