【发布时间】:2022-07-18 23:15:08
【问题描述】:
我提前道歉,我无法创建可重现的示例,但是当我在某些数据帧上执行 tidyr::crossing 时,我得到一个交叉的小标题,其中 x 变量具有以下形式:x$col_name 和 y变量有y$col_name。如果我这样做:
crossing(iris,mtcars)
根据需要,我得到没有x$ 前缀的名称。我检查了输入数据框的类是否与上面的示例相同,并且我正在使用的示例中没有重复的名称。由于通常的隐私原因,我无法共享数据。我意识到这里没有太多工作要做,但我希望这里的人对tidyr 有足够的经验来理解这个问题。
这里是一些会话信息:
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] writexl_1.4.0 readxl_1.4.0 lubridate_1.8.0 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.9
[7] purrr_0.3.4 readr_2.1.2 tidyr_1.2.0 tibble_3.1.7 ggplot2_3.3.6 tidyverse_1.3.1
loaded via a namespace (and not attached):
[1] cellranger_1.1.0 pillar_1.7.0 compiler_4.2.0 dbplyr_2.2.0 tools_4.2.0
[6] jsonlite_1.8.0 lifecycle_1.0.1 gtable_0.3.0 pkgconfig_2.0.3 rlang_1.0.2
[11] reprex_2.0.1 rstudioapi_0.13 DBI_1.1.3 cli_3.3.0 haven_2.5.0
[16] xml2_1.3.3 withr_2.5.0 httr_1.4.3 fs_1.5.2 generics_0.1.2
[21] vctrs_0.4.1 hms_1.1.1 grid_4.2.0 tidyselect_1.1.2 glue_1.6.2
[26] R6_2.5.1 fansi_1.0.3 tzdb_0.3.0 modelr_0.1.8 magrittr_2.0.3
[31] backports_1.4.1 scales_1.2.0 ellipsis_0.3.2 rvest_1.0.2 assertthat_0.2.1
[36] colorspace_2.0-3 utf8_1.2.2 stringi_1.7.6 munsell_0.5.0 broom_0.8.0
[41] crayon_1.5.1
【问题讨论】:
-
你有那些数据集中常见的列名。请检查这些数据集的
str。 -
列名不同。让我知道我还能调查什么...谢谢。
-
正如我所提到的,您可以检查那些给出不寻常结果的数据集的
str与给出正确结果的数据集相比。那些一定是有什么事情发生了。如果您可以显示此处编辑的str输出,它可能对其他人有所帮助 -
我想通了,请看下面我的回答。