我有 ~500 个 CSV 文件,每个文件有 5000 行和 1000 列 (~20Mb)。我想按列附加它们并保存为大型 CSV 文件。
之前的一篇文章部分回答了这个问题。 awk 按列合并多个 csv 文件,不匹配
但是有没有一种方法可以做到这一点而不必写出每个文件名?我的文件按顺序命名(例如,X1.csv、X2.csv、X3.csv、...、X500.csv),如果有帮助的话。
与一篇热门帖子类似,我想修改以下代码(来自R文档中的examples ()命令示例):
## put (absolute) correlations on the upper panels,
## with size proportional to the correlations.
panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- abs(cor(x, y))
txt <- format(c(r, 0.123456789), digits = digits)[1]
txt <- paste0(prefix, txt)
if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex.cor * r)
}
pairs(USJudgeRatings, lower.panel = panel.smooth, upper.panel = …Run Code Online (Sandbox Code Playgroud) 给定以下样本数据集:
col1 <- c("X1","X2","X3|X4|X5","X6|X7")
col2 <- c("5","8","1","4")
dat <- data.frame(col1,col2)
Run Code Online (Sandbox Code Playgroud)
如何分割col1by |并将其作为具有重复col2值的单独行输入?这是我想要最终得到的数据框:
col1 col2
X1 5
X2 8
X3 1
X4 1
X5 1
X6 4
X7 4
Run Code Online (Sandbox Code Playgroud)
我需要一个可以容纳多个类似列的解决方案,col2也需要重复该解决方案。