[英]R: Error Running Example Code for reduce() from purrr package
我正在尋找使用 reduce() 將數據幀中的可變數量的列成對連接起來。 看起來 reduce() 可以完成這項工作,所以我嘗試了一些示例代碼並得到了這個錯誤。 我正在使用 RStudio,版本 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這是我的第一個問題,所以我試圖在太多信息方面犯錯。 如果我需要提供不同/更多/更少的信息,請告訴我。
正如評論中所說,有一個名為c
的變量掩蓋了函數c
。
永遠不要命名任何c
,除了列表元素或列名。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.