I'm looking to use reduce() to concatenate a variable number of columns from a data frame pairwise. It looked like reduce() would do the job, so I tried some of the example code and got this error. I'm using RStudio, Version 1.0.136
> require(tidyverse)
> x <- list(c(0, 1), c(2, 3), c(4, 5))
> x %>% reduce(c)
# Error: `x` must be a vector (not a NULL)
> sessionInfo()
# R version 3.3.2 (2016-10-31)
# Platform: x86_64-apple-darwin13.4.0 (64-bit)
# Running under: OS X El Capitan 10.11.6
# locale:
# [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
# attached base packages:
# [1] stats graphics grDevices utils datasets methods base
# other attached packages:
# [1] dplyr_0.5.0 purrr_0.2.2 readr_1.0.0 tidyr_0.6.1 tibble_1.2 ggplot2_2.2.1
# [7] tidyverse_1.1.1
# loaded via a namespace (and not attached):
# [1] Rcpp_0.12.9 xml2_1.1.1 magrittr_1.5 hms_0.3 rvest_0.3.2 mnormt_1.5-5
# [7] munsell_0.4.3 colorspace_1.3-2 lattice_0.20-34 R6_2.2.0 httr_1.2.1 stringr_1.1.0
# [13] plyr_1.8.4 tools_3.3.2 parallel_3.3.2 grid_3.3.2 broom_0.4.1 nlme_3.1-130
# [19] gtable_0.2.0 psych_1.6.12 DBI_0.5-1 modelr_0.1.0 readxl_0.1.1 lazyeval_0.2.0
# [25] assertthat_0.1 reshape2_1.4.2 haven_1.0.0 stringi_1.1.2 forcats_0.2.0 scales_0.4.1
# [31] lubridate_1.6.0 jsonlite_1.2 foreign_0.8-67
PS This is my first question, so I tried to err on the side of too much info. Let me know if I need to provide different/more/less information.
As said in comments there was a variable named c
that masked the function c
.
Don't ever name anything c
, except maybe list elements or column names.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.