简体   繁体   English

Glue 列规范中的“fn”和“col”arguments 在哪里命名 dplyr 中的列(使用 `across` 和 `where` 来自哪里?

[英]Where do the “fn” and “col” arguments to the Glue column specifications to name columns in dplyr (using `across` and `where` come from?

I was going through the vignette ( https://cran.r-project.org/web/packages/dplyr/vignettes/colwise.html ) for column-wise options in dplyr and I came across this: (copied verbatim from the vignette) I was going through the vignette ( https://cran.r-project.org/web/packages/dplyr/vignettes/colwise.html ) for column-wise options in dplyr and I came across this: (copied verbatim from the vignette )


Control how the names are created with the.names argument which takes a glue spec:使用带有胶合规范的 .names 参数控制如何创建名称:

starwars %>% summarise(across(where(is.numeric), min_max, .names = "{fn}.{col}"))
#> # A tibble: 1 x 6
#>   min.height max.height min.mass max.mass min.birth_year max.birth_year
#>        <int>      <int>    <dbl>    <dbl>          <dbl>          <dbl>
#> 1         66        264       15     1358              8            896

My question is: where did the variables fn and col come from?我的问题是:变量fncol是从哪里来的? I don't see anything about that on the main Glue vignette.我在主要的Glue小插图上看不到任何关于此的内容。 The corresponding arguments to across are .fns and .cols so I don't see the exact correspondence.对应的across.fns.cols所以我看不到确切的对应关系。 This seems like too obscure an issue for me to be going on a wild goose chase through the documentation so I was hoping that someone could point me in the right direction.这对我来说似乎太模糊了,无法通过文档进行疯狂的追逐,所以我希望有人能指出我正确的方向。

From the online help for across :来自cross的在线across

.names .names
A glue specification that describes how to name the output columns.描述如何命名 output 列的粘合规范。 This can use {col} to stand for the selected column name, and {fn} to stand for the name of the function being applied.这可以使用{col}代表选定的列名,使用{fn}代表正在应用的 function 的名称。 The default ( NULL ) is equivalent to {col} for the single function case and {col}_{fn} for the case where a list is used for .fns .对于单个 function 情况,默认值 ( NULL ) 等效于{col} ,对于将列表用于.fns的情况,则等效于 { {col}_{fn}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 dplyr 查找列在一行中的排名? - How to find where a column ranks across a row using dplyr? Dplyr:对 R 中的多个整列使用 mutate、cross、where 和 ìfelse - Dplyr: using mutate , across , where and ìfelse to multiple entire column in R 从 dplyr 中的变量中引用列名 - refer to column name from variable in across in dplyr 关于在 `dplyr::across()` 中使用 `where()` 的警告以及使用时的错误 - Warning about using `where()` in `dplyr::across()` and errors when using it R - 使用来自 dplyr 的变异 function 创建了错误的列名 - R - using mutate function from dplyr creates the wrong col name 使用 dplyr、across()、where() 和 if_else() 函数将 NA 替换为数字 - Using dplyr, across(), where() and if_else() functions to replace NA by a number 使用 dplyr summarise() 和 cross() 以及基于胶水的格式不会产生预期的列名 - using dplyr summarise() with across() with glue-based formatting does not produce column names as expected 使用 dplyr 中的列名向量在列中查找行最大值 - Find row maximum across columns by using vector of column names in dplyr 使用dplyr返回两行中第一个字符匹配而两行不匹配的行 - Using dplyr to return rows where first character in two columns match and the two rows DO NOT match 在 ifelse 条件和函数下创建多个列,其中参数取决于输出列的名称 - Create multiple columns under ifelse conditions and functions, where arguments depend on name of output-column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM