gpt4 book ai didi

r - 为什么切片函数在没有显式使用dplyr的情况下不起作用

转载 作者:行者123 更新时间:2023-12-04 23:08:14 27 4
gpt4 key购买 nike

我正在学习使用dplyr并遇到了功能片。我试着在没有显式dplyr的情况下调用它。

它与显式调用一起使用,但是在没有dplyr的情况下调用会产生错误。有人可以指导我该错误的根源是什么?

据我所知,slice函数是dplyr专有的,还是它也属于其他软件包?

> library("tidyverse") 
> sessionInfo()

R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.14.1

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.5/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats4 parallel stats graphics grDevices utils datasets methods base

other attached packages:
[1] faraway_1.0.7 pd.hg.u95av2_3.12.0 DBI_1.0.0 oligo_1.46.0 oligoClasses_1.44.0
[6] RSQLite_2.1.1 Biostrings_2.50.2 XVector_0.22.0 IRanges_2.16.0 S4Vectors_0.20.1
[11] ArrayExpress_1.42.0 Biobase_2.42.0 BiocGenerics_0.28.0 bindrcpp_0.2.2 forcats_0.3.0
[16] stringr_1.3.1 dplyr_0.7.8 purrr_0.2.5 tidyr_0.8.2 tibble_2.0.0
[21] ggplot2_3.1.0 tidyverse_1.2.1 readr_1.3.1

loaded via a namespace (and not attached):
[1] nlme_3.1-137 bitops_1.0-6 matrixStats_0.54.0
[4] lubridate_1.7.4 bit64_0.9-7 httr_1.4.0
[7] GenomeInfoDb_1.18.1 tools_3.5.1 backports_1.1.3
[10] utf8_1.1.4 R6_2.3.0 affyio_1.52.0
[13] lazyeval_0.2.1 colorspace_1.3-2 withr_2.1.2
[16] tidyselect_0.2.5 bit_1.1-14 curl_3.3
[19] compiler_3.5.1 preprocessCore_1.44.0 cli_1.0.1
[22] rvest_0.3.2 xml2_1.2.0 DelayedArray_0.8.0
[25] labeling_0.3 scales_1.0.0 digest_0.6.18
[28] minqa_1.2.4 pkgconfig_2.0.2 lme4_1.1-19
[31] limma_3.38.3 rlang_0.3.1 readxl_1.2.0
[34] rstudioapi_0.9.0 bindr_0.1.1 generics_0.0.2
[37] jsonlite_1.6 BiocParallel_1.16.5 RCurl_1.95-4.11
[40] magrittr_1.5 GenomeInfoDbData_1.2.0 Matrix_1.2-15
[43] Rcpp_1.0.0 munsell_0.5.0 fansi_0.4.0
[46] stringi_1.2.4 yaml_2.2.0 MASS_7.3-51.1
[49] SummarizedExperiment_1.12.0 zlibbioc_1.28.0 plyr_1.8.4
[52] grid_3.5.1 affxparser_1.54.0 blob_1.1.1
[55] crayon_1.3.4 lattice_0.20-38 haven_2.0.0
[58] splines_3.5.1 hms_0.4.2 pillar_1.3.1
[61] GenomicRanges_1.34.0 codetools_0.2-16 XML_3.98-1.16
[64] glue_1.3.0 BiocManager_1.30.4 modelr_0.1.2
[67] nloptr_1.2.1 foreach_1.4.4 cellranger_1.1.0
[70] gtable_0.2.0 assertthat_0.2.0 broom_0.5.1
[73] ff_2.2-14 iterators_1.0.10 memoise_1.1.0

> worldcup %>% dplyr::slice(1:3)


Team Position Time Shots Passes Tackles Saves player_name

1 Algeria Midfielder 16 0 6 0 0 Abdoun

2 Japan Midfielder 351 0 101 14 0 Abe

3 France Defender 180 0 91 6 0 Abidal

> worldcup %>% slice(1:3)

Error in .Call2("Rle_constructor", values, lengths, PACKAGE = "S4Vectors") :

Rle of type 'list' is not supported

最佳答案

worldcup %>% slice(1:3)slice包而不是dplyr调用S4Vectors

尝试做:

detach("package:S4Vectors")

然后运行:

worldcup %>% slice(1:3)

关于r - 为什么切片函数在没有显式使用dplyr的情况下不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54160319/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com