Description Arguments Value Author(s) Examples
Replaces a variable in the dataframe.
df |
dataframe. The dataframe to modify. |
fun |
function. The function to run to convert the input into the new input. Whichever argument is passed first to the function is the variable that will be replaced. |
Does not return anything, but modifies-in-place the dataframe to replace that variable.
Peter Hurford
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Repaces Sepal.Width to add 1 to each datapoint.
replace_variable()$run(iris, function(Sepal.Width) { Sepal.Width + 1 })
# Repaces Sepal.Length to add the corresponding Sepal.Width to each datapoint for Sepal.Length.
replace_variable()$run(iris, function(Sepal.Length, Sepal.Width) { Sepal.Width + Sepal.Length })
# Usage in a Syberia file
## Not run:
list("Replace Sepal.Length with Sepal.Length + 1" = list(
replace_variable,
function(Sepal.Length) Sepal.Length + 1
))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.