【发布时间】:2018-05-19 21:31:54
【问题描述】:
我想将下面的示例 excel 数据集 sample.xlsx 导入 R。
OrderDate Region Rep Item Units UnitCost Total
1/6/2016 East Jones Pencil 95 1.99 189.05
1/23/2016 Central Kivell Binder 50 19.99 999.5
2/9/2016 Central Jardine Pencil 36 4.99 179.64
2/26/2016 Central Gill Pen 27 19.99 539.73
3/15/2016 West Sorvino Pencil 56 2.99 167.44
4/1/2016 East Jones Binder 60 4.99 299.4
当我像往常一样使用下面的代码时,我收到了一个错误。
library(readxl)
df <- read_excel("~/sample.xlsx")
Error in is_atomic(x) : object 'rlang_is_atomic' not found
我什至尝试重新启动 R 并重新安装 rlang 然后重新启动 R 和计算机但无济于事。
另外,我尝试将sample.xlsx保存为sample.csv,然后使用library(readr)和read_csv导入,也没有成功。
请帮助我了解我的方法有什么问题以及如何解决这个问题。
以下是我的会话信息:
sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] ggpubr_0.1.6 magrittr_1.5 reshape2_1.4.3
[4] readxl_1.0.0 brms_2.1.0 Rcpp_0.12.16
[7] betareg_3.1-0 zoib_1.5.1 abind_1.4-5
[10] Formula_1.2-2 matrixcalc_1.0-3 rjags_4-6
[13] coda_0.19-1 stringr_1.3.0 dplyr_0.7.4
[16] purrr_0.2.4 readr_1.1.1 tidyr_0.8.0
[19] tibble_1.4.2 ggplot2_2.2.1.9000 tidyverse_1.2.1
loaded via a namespace (and not attached):
[1] nlme_3.1-131.1 matrixStats_0.53.1
[3] xts_0.10-2 lubridate_1.7.3
[5] threejs_0.3.1 httr_1.3.1
[7] rstan_2.17.3 tools_3.4.2
[9] R6_2.2.2 DT_0.4
[11] lazyeval_0.2.1 colorspace_1.3-2
[13] nnet_7.3-12 withr_2.1.2
[15] gridExtra_2.3 mnormt_1.5-5
[17] Brobdingnag_1.2-5 compiler_3.4.2
[19] cli_1.0.0 rvest_0.3.2
[21] shinyjs_1.0 xml2_1.2.0
[23] sandwich_2.4-0 colourpicker_1.0
[25] scales_0.5.0.9000 dygraphs_1.1.1.4
[27] lmtest_0.9-36 mvtnorm_1.0-7
[29] psych_1.8.3.3 ggridges_0.5.0
[31] digest_0.6.15 StanHeaders_2.17.2
[33] foreign_0.8-69 base64enc_0.1-3
[35] pkgconfig_2.0.1 htmltools_0.3.6
[37] htmlwidgets_1.2.1 rlang_0.2.0.9001
[39] rstudioapi_0.7 shiny_1.0.5
[41] bindr_0.1.1 zoo_1.8-1
[43] jsonlite_1.5 crosstalk_1.0.0
[45] gtools_3.5.0 inline_0.3.14
[47] modeltools_0.2-21 loo_1.1.0
[49] bayesplot_1.5.0 Matrix_1.2-12
[51] munsell_0.4.3 stringi_1.1.7
[53] flexmix_2.3-14 plyr_1.8.4
[55] grid_3.4.2 parallel_3.4.2
[57] forcats_0.3.0 crayon_1.3.4
[59] miniUI_0.1.1 lattice_0.20-35
[61] haven_1.1.1 hms_0.4.2
[63] pillar_1.2.1 igraph_1.2.1
[65] markdown_0.8 shinystan_2.4.0
[67] stats4_3.4.2 rstantools_1.4.0
[69] glue_1.2.0 modelr_0.1.1
[71] httpuv_1.3.6.2 cellranger_1.1.0
[73] gtable_0.2.0 assertthat_0.2.0
[75] mime_0.5 xtable_1.8-2
[77] broom_0.4.3 rsconnect_0.8.8
[79] shinythemes_1.1.1 bindrcpp_0.2.2
[81] bridgesampling_0.4-0
【问题讨论】:
-
嗨@Aurèle。谢谢,但不起作用。它说:
Error: 'OrderDate Region Rep Item Units UnitCost Total 1/6/2016 East Jones Pencil 95 1.99 189.05 1/23/2016 Central Kivell Binder 50 19.99 999.5 2/9/2016 Central Jardine Pencil 36 4.99 179.64 2/26/2016 Central Gill Pen 27 19.99 539.73 3/15/2016 West Sorvino Pencil 56 2.99 167.44 4/1/2016 East Jones Binder 60 4.99 299.4' does not exist in current working directory ('C:~/Documents') -
抱歉,我在 cmets 中遇到了文本格式问题。
readr::read_delim("OrderDate Region Rep Item Units UnitCost Total\n1/6/2016 East Jones Pencil 95 1.99 189.05\n1/23/2016 Central Kivell Binder 50 19.99 999.5\n2/9/2016 Central Jardine Pencil 36 4.99 179.64\n2/26/2016 Central Gill Pen 27 19.99 539.73\n3/15/2016 West Sorvino Pencil 56 2.99 167.44\n4/1/2016 East Jones Binder 60 4.99 299.4\n", delim = " ")呢? -
现在显示:
Error in read_tokens_(data, tokenizer, col_specs, col_names, locale_, : Evaluation error: object 'rlang_is_atomic' not found. -
您使用
rlang的开发版本是否有特殊原因?否则你可以从 CRAN 重新安装它吗? (我尝试使用相同的开发版本但无法重现,但仍然值得一试) -
谢谢。卸载
rlang然后安装其 CRAN 版本后问题解决。请将此解决方案作为答案发布,以便我可以正式接受它并使其他用户更容易找到该解决方案。