-
Notifications
You must be signed in to change notification settings - Fork 283
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behaviorwipwork in progresswork in progress
Description
The documentation for modify
says that the .x
parameter is "A list or atomic vector." and the "Value" section says that the functions will return "An object the same class as .x
" However for atomic vectors, it seems to return a list, and not a vector of the same class as .x
.
x <- c("a","b","c","d","e")
y <- c(1, 2, 3, 4, 5)
z <- c(T, F, T, F, T)
class(modify(x,function(x) "k"))
# [1] "list" ## not class(x)
class(modify(y,function(x) 10))
# [1] "list" ## not class(y)
class(modify_if(x, z, function(x) "k"))
# [1] "list" ## not class(x)
class(modify_if(y, z, function(x) x+10))
# [1] "list" ## not class(y)
The help page also says that modify()
is basically the same as x[] <- map(x, .f)
and ifs that's the case i'd expect map()
to return a list, But even on the ?map
help page it calls out: "See the modify()
family for versions that return an object of the same type as the input."
Tested with purrr_0.2.4
and R version 3.4.1 (2017-06-30)
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behaviorwipwork in progresswork in progress