这里有一个问题 - 我正在使用 eclipse 参数创建一个函数来处理不同的函数参数。我重新创建了类似的情况以显示我不断遇到的问题,
> d <- data.frame(alpha=1:3, beta=4:6, gamma=7:9)
> d
alpha beta gamma
1 1 4 7
2 2 5 8
3 3 6 9
> x <- list("alpha", "beta")
> rowSums(d[,c(x)])
Error in .subset(x, j) : invalid subscript type 'list'
Run Code Online (Sandbox Code Playgroud)
如何处理将列表提供给子集调用的问题?
尝试安装devtools,但不断出现错误
Error : object ‘glue_collapse’ is not exported by 'namespace:glue'
ERROR: lazy loading failed for package ‘usethis’
以下是完整的错误代码:
> install.packages('devtools', repos='http://cran.rstudio.com/')
also installing the dependency ‘usethis’
There are binary versions available but
the source versions are later:
binary source needs_compilation
usethis 1.4.0 1.5.0 FALSE
devtools 1.13.6 2.0.2 FALSE
installing the source packages ‘usethis’, ‘devtools’
trying URL 'http://cran.rstudio.com/src/contrib/usethis_1.5.0.tar.gz'
Content type 'application/x-gzip' length 393903 bytes (384 KB)
==================================================
downloaded 384 KB
trying URL 'http://cran.rstudio.com/src/contrib/devtools_2.0.2.tar.gz'
Content type 'application/x-gzip' length 388141 bytes (379 KB) …Run Code Online (Sandbox Code Playgroud) 快速提问,
如果我有两个数据框,其重叠列的顺序不匹配,例如:
df1
Chocolate Strawberry
2 15
3 10
4 5
df2
Strawberry Chocolate Vanilla
14 4 30
9 4 15.2
5 4 10
Run Code Online (Sandbox Code Playgroud)
我想仅减去匹配列的两个数据帧,并忽略任何不重叠的列。
期望的结果:
Chocolate Strawberry
-2 1
-1 1
0 0
Run Code Online (Sandbox Code Playgroud)
示例代码:
df1 <- data.frame(chocolate = c(2,3,4), strawberry = c(15,10,5))
df2 <- data.frame(strawberry = c(14,9,5), chocolate = c(4,4,4), vanilla = c(30,15.2,10))
Run Code Online (Sandbox Code Playgroud) 我的表单中有一个连续的子表单,显示多个提醒 - 它大约有 6 列,最后一列有复选框,如果提醒已完成,您可以在其中勾选它。如果选中最后一列,是否可以为框着色?
快速问题 - 我想在 SQL Server 中创建另一列,例如:
原表
Type Amount LocNum
Chocolate 15 WC-10202-01
Banana 10 WC-35209-22
Vanilla 5 WC-15815-15
Run Code Online (Sandbox Code Playgroud)
理想的桌子
Type Amount LocNum LocNum2
Chocolate 15 WC-10202-01 WC-10202
Banana 10 WC-35209-22 WC-35209
Vanilla 5 WC-15815-15 WC-15815
Run Code Online (Sandbox Code Playgroud) 所以有一种情况:
数据帧:
dat <- data.frame(colA = rep(c(0,1,0), c(6,1,8)),
colB = rep(c(1,0,1,0), c(1,4,1,9)),
colC = rep(c(0,1,0), c(9,1,5)),
colD = rep(c(0,1,0), c(8,1,6)),
colE = rep(0, 15),
color = rep(c("blue","red","yellow"), each=5),
colorId = rep(c(22,40,35), each=5))
colA colB colC colD colE color colorId
0 1 0 0 0 Blue 22
0 0 0 0 0 Blue 22
0 0 0 0 0 Blue 22
0 0 0 0 0 Blue 22
0 0 0 0 0 Blue 22
0 1 0 0 0 Red …Run Code Online (Sandbox Code Playgroud)