View source: R/prune_01-A_prune.R
prune | R Documentation |
Identify rows for prunning.
prune(data, id = NA_character_, prune_var = "prune_id", func = NULL, cols, ...)
data |
Dataframe. |
id |
String. ID used to identify the rows in column |
prune_var |
The name of the column with the prune id. Default is "prune_id". |
func |
Function used to select the rows meeting the condition for
prunning. Default is |
cols |
Names of columns to apply |
... |
Additional arguments used by |
Set the column prune_var
to id
if the condition defined by
func
is met.
Dataframe with updated prune_var
column.
When func = NULL
and id = NA_character_
and the column does not
exist, then it will be created and filled with NA
. If the column
the column prune_var
already exists, an error will be issued. If you
intend to reset the column values to NA
, just delete it and create
When func = NULL
and id != NA_character
, then an error message
will be issued as an id
cannot exist without a corresponding function.
When func != NULL
and id != NA_character
, then all elements
of column prune_var
selected by func
will be set to id
if they are NA or already set to id, that is the rows with a
pre-existing value other than id
will be kept as is. This is
necessary to ensure that previous id are kept which is very useful when some
id are subsets of others be must be kept. For example when one wants to
keep zeros be exclude other values in a range then we would prune for zeros
then prune for the range.
When func != NULL
and id = NA_character
, then an error message
will be issued as a function must always have a corresponding id
.
prune_proc
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.