- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个函数将省略号参数计算为列名。这些函数(sub_fun_1 和 sub_fun_2)使用这些列名来对输入的数据帧进行分组。
main_fun <- function(df1, df2, ...) {
columns <- enquos(...) ### '...' arguments used to specify columns in data-sets
df1_grouped <- sub_fun_1(df1, columns) ### Evaluates 'columns' and groups df1 by column names
df2_grouped <- sub_fun_2(df2, columns) ### Evaluates 'columns' and groups df2 by column names
}
sub_fun_1 <- function(df1, columns) {
df1_grouped <- df1 %>%
group_by(!!! columns)
}
sub_fun_2 <- function(df2, columns) {
df2_grouped <- df2 %>%
group_by(!!! columns)
}
最佳答案
一种选择是使用 intersect
转换为字符后
library(dplyr)
library(purrr)
main_fun <- function(data1, data2, ...) {
columns <- map_chr(enquos(...), rlang::quo_name)
sub_fun1 <- data1 %>%
group_by_at(vars(intersect(names(.), columns)))
sub_fun2 <- data2 %>%
group_by_at(vars(intersect(names(.), columns)))
list(sub_fun1, sub_fun2)
}
main_fun(iris, mtcars, gear, vs, Species)
#[[1]]
# A tibble: 150 x 5
# Groups: Species [3]
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
# <dbl> <dbl> <dbl> <dbl> <fct>
# 1 5.1 3.5 1.4 0.2 setosa
# 2 4.9 3 1.4 0.2 setosa
# 3 4.7 3.2 1.3 0.2 setosa
# 4 4.6 3.1 1.5 0.2 setosa
# 5 5 3.6 1.4 0.2 setosa
# 6 5.4 3.9 1.7 0.4 setosa
# 7 4.6 3.4 1.4 0.3 setosa
# 8 5 3.4 1.5 0.2 setosa
# 9 4.4 2.9 1.4 0.2 setosa
#10 4.9 3.1 1.5 0.1 setosa
# … with 140 more rows
#[[2]]
# A tibble: 32 x 11
# Groups: vs, gear [6]
# mpg cyl disp hp drat wt qsec vs am gear carb
# <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
# 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
# 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
# 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
# 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
# 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
# 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
# 7 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4
# 8 24.4 4 147. 62 3.69 3.19 20 1 0 4 2
# 9 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2
#10 19.2 6 168. 123 3.92 3.44 18.3 1 0 4 4
# … with 22 more rows
关于r - 有没有办法将特定的省略号参数仅应用于某些函数,而不是其他函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60495675/
我正在制作一款打算在 future 进行本地化的软件。我想知道省略号(...指示一个 Action 打开一个新窗口/对话框)通常是如何本地化的。 所有语言都这样使用省略号吗?我可以在自己的代码中安全地
我正在尝试实现以下布局(请参阅下面的屏幕截图)。 如果 SPAN 和 B 都符合条件 - 它们只是一个接一个。 如果没有 - SPAN 有一个省略号,但 B 完全显示(它永远不会大于整个 block
我理解点-点-点的一般含义。当我想创建自己的参数数量未知的函数时,我了解如何使用它。 我不明白它是如何工作的,例如函数 variable.names()。当我执行 ?variable.names 时,
在 jqGrid 中,如果文本不适合并被截断,是否有一种本地方法可以在列末尾显示“...”? 我看到有一个 ui-ellipsis 类,但我很困惑,如果文本被截断,它是否会自动添加,以及一旦调整列大小
我有几个 JS 语法问题。 首先,有什么好的资源可以帮助您快速掌握与以下类似的 JS 语法? 代码中,Q1和Q2是标签吗?另外,...的用途是什么? const Q1: Query = { 'is
我正在阅读一些旧代码,这些代码似乎旨在删除目录中的一系列句点 (......)。它利用 java 正则表达式来完成此操作。这是使用的代码。 input = input.replaceAll( ".*.
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and t
我正在尝试让省略号像这样工作:http://jsfiddle.net/583mK/1/ 有趣的是,它在 jsFiddle 上运行良好。奇怪的是,它提供了完全相同的 HTML/CSS,但它在我的应用程序
我有多个不同长度的标题,我希望它们总是占用 1 行并在它们不适合时留下悬挂点/省略号 (...)。我不能只更改 div 中的文本,因为其中的 h2 每天都会自动更改。 这是我的代码:http://js
有十亿个教程,但不幸的是,没有一个对我有用。我需要一些艺术家姓名在标题中,居中,但带有 css 省略号,所以很长的名字会得到“...”并将被截断。 您可以在此处查看设计:http://www.cphr
这个问题在这里已经有了答案: text overflow ellipsis: avoid word break (3 个答案) 关闭 3 年前。 我正在显示带有省略号的文本。在我当前的 CSS 中,
我要画圈 ,就像这张图片: 我试过这段代码。 .discussion:after { content: '\2807'; font-size: 1em; background: #2d34
我在玩python。我在 IDLE 中使用了以下代码: p = [1, 2] p[1:1] = [p] print p 输出是: [1, [...], 2] 这是什么[…]?有趣的是,我现在可以将其
我对省略号很陌生,但即使我将变量分配为 false,以下内容也会返回 true。 PS:注意 if 条件。 import system.obj.* from elipsis.system; iff(e
我正在使用 alabama 包中的 constrOptim.nl 进行非线性优化。但是,我的问题更多地与传递参数(和点-点-点(省略号/“...”)和可能的 do.call)有关 - 所以我首先给出一
例如,我知道如何使用 numpy 对数组进行切片 v[1, :, :] 现在我想要一个函数将切片 (1,1,None) 作为输入并返回 v[1,:,:] 问题是我不知道如何表示省略号 最佳答案 您可以
我有一个宽度设置为 100%。里面是一个带有文本字符串的 div,如果文本宽度溢出,我想在其中添加省略号。 在 javascript 中,我设置了 的宽度到 的宽度这在加载(或刷新)时工作正常,但
有什么方法可以使用 Angular js 对字符串进行子串并在末尾添加省略号,同时忽略 anchor 标记(如果它位于子字符串内部)? 例如,我的文字是: Lorem Ipsum has been t
我不知道为什么这个简单的CSS无法正常工作... .app a { height: 18px; width: 140px; padding: 0; overflow: hidden;
这个问题在这里已经有了答案: text-overflow is not working when using display:flex (5 个答案) 关闭 3 年前。
我是一名优秀的程序员,十分优秀!