所以,我有一个数据框列表,命名为"D1.txt", "D2.txt"................"D45.txt".
Each of the file contains
2列,每个文件有1000行.
我基本上尝试通过以下代码向列表中的每个数据框添加一个新列,但它显示错误为
incorrect number of subscripts on matrix
.
我正在使用的代码是,
L <- lapply(seq_along(L), function(i) {
L[[i]][, paste0('DF', i)] <- 1
L[[i]]
})
Run Code Online (Sandbox Code Playgroud)
where L
包含数据框的列表的名称.
为什么会出现这个错误?谢谢!:)
编辑:一个重复的例子:
# Create dummy data
L <- replicate(5, expand.grid(1:10, 1:10)[sample(100, 10), ], simplify=FALSE)
# Add a column to each data.frame in L.
# This will indicate presence of the pair when we merge.
L <- lapply(seq_along(L), function(i) {
L[[i]][, paste0('DF', i)] <- 1
L[[i]]
})
Run Code Online (Sandbox Code Playgroud) 我做了这个小程序只是想知道如何在C中进行逻辑移位.
#include <stdio.h>
int main (void)
{
int n=-2,t;
t = (int)((unsigned int)n >> 1);
printf("%d\n",t);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,它输出
2147283747.我在这里遗漏了什么吗?答案不应该是7?