It seems as if creating a column with dplyr::mutate() does not allow vector recycling. Why?
Example:
require(dplyr)
df <- data_frame(id = rep(1:5, each = 42), name = rep(letters[1:7], each = 6, times = 5))
now:
df %>% mutate (tp = c(1:42)) #results in
Error in mutate_impl(.data, dots) :
Column `tp` must be length 210 (the number of rows) or one, not 42
but of course
df$tp <- c(1:42) #works
Is my mutate code wrong or does recycling simply not work in mutate()?
If it helps, I am using dplyr 0.7.2 with RStudio 1.0.153 (Mac)
transform. CompareBOD %>% transform(a = 1:2)andBOD %>% mutate(a = 1:2). - G. Grothendieck