[英]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?我的问题是:变量
fn
和col
是从哪里来的? 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.