powered by
Modifies elements of a vector selectively, similar to the functions in purrr.
modify_if() applies a predicate function .p to all elements of .x and applies .f to those elements of .x where .p evaluates to TRUE.
modify_if()
.p
.x
.f
TRUE
modify_at() applies .f to those elements of .x selected via .at.
modify_at()
.at
modify_if(.x, .p, .f, ...)modify_at(.x, .at, .f, ...)
modify_at(.x, .at, .f, ...)
(vector()).
vector()
(function()) Predicate function.
function()
(function()) Function to apply on .x.
(any) Additional arguments passed to .f.
any
((integer() | character())) Index vector to select elements from .x.
integer()
character()
x = modify_if(iris, is.factor, as.character) str(x) x = modify_at(iris, 5, as.character) x = modify_at(iris, "Sepal.Length", sqrt) str(x)
Run the code above in your browser using DataLab