解決した
次の例で何が問題なのかを理解するのを手伝ってください。
library(tidyverse)
(freq <- structure(list(Year_of_diagnosis = c(2004L, 2004L, 2005L, 2005L,
2006L, 2006L, 2007L, 2007L, 2008L, 2008L, 2009L, 2009L, 2010L,
2010L, 2011L, 2011L, 2012L, 2012L, 2013L, 2013L, 2014L, 2014L),
Sex = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Female", "Male"), class = "factor"),
n = c(70L, 180L, 70L, 170L, 70L, 180L, 60L, 220L, 80L, 190L, 80L, 230L, 60L, 210L, 70L, 230L,
70L, 220L, 70L, 220L, 80L, 230L)),
class = c("tbl_df", "tbl", "data.frame"), .Names = c("Year", "Sex", "n"), row.names = c(NA, -22L)))
問題はここにあります:
tidyr::spread(freq, key = Sex, value = n)
次のエラーが発生します。
matrixToDataFrame(x) のエラー: オブジェクト '_tibble_matrixToDataFrame' が見つかりません
まだパッケージを更新していません:
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_0.7.2 purrr_0.2.3 readr_1.1.1 tidyr_0.7.0 tibble_1.3.4 ggplot2_2.2.1 tidyverse_1.1.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.12 cellranger_1.1.0 compiler_3.4.1 plyr_1.8.4 bindr_0.1 forcats_0.2.0 tools_3.4.1 lubridate_1.6.0
[9] jsonlite_1.5 nlme_3.1-131 gtable_0.2.0 lattice_0.20-35 pkgconfig_2.0.1 rlang_0.1.2 psych_1.7.5 parallel_3.4.1
[17] haven_1.1.0 bindrcpp_0.2 xml2_1.1.1 stringr_1.2.0 httr_1.3.1 hms_0.3 tidyselect_0.2.0 grid_3.4.1
[25] glue_1.1.1 R6_2.2.2 readxl_1.0.0 foreign_0.8-69 modelr_0.1.1 reshape2_1.4.2 magrittr_1.5 scales_0.5.0
[33] rvest_0.3.2 assertthat_0.2.0 mnormt_1.5-5 colorspace_1.3-2 stringi_1.1.5 lazyeval_0.2.0 munsell_0.4.3 broom_0.4.2
eipi10 のセッション情報:
R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
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.7.2 tidyr_0.7.0
loaded via a namespace (and not attached):
[1] tidyselect_0.1.1 compiler_3.4.1 assertthat_0.2.0 R6_2.2.2 magrittr_1.5 tools_3.4.1 bindrcpp_0.2 glue_1.1.1 tibble_1.3.4
[10] yaml_2.1.14 Rcpp_0.12.12 pkgconfig_2.0.1 rlang_0.1.2 bindr_0.1 purrr_0.2.3
更新: [@aosmith の功績]tidyverse
新しいセッションでの再インストールが役立ちました。