可以为其自身添加一个 data.frame 吗?
我想向其自身追加或添加一个 data.frame... 与补充的方式大致相同:
n <- n + t
我有一个创建 data.frame 的函数。
我一直在使用:
g <- function(compareA,compareB) {
for (i in 1:1000) {
ttr <- t.test(compareA, compareA, var.equal = TRUE)
tt_pvalues[i] <- ttr$p.value
}
name_tag <- paste(nameA, nameB, sep = "_Vs_")
tt_titles <- data.frame(name_tag, tt_titles)
# character vector which I want to add to a list
ALL_pvalues <- data.frame(tt_pvalues, ALL_pvalues)
# adding a numeric vector of values to a larger data.frame
}
cbind
这里会更好吗?
I want to append or add a data.frame to itself...
Much in the same way the one adds:
n <- n + t
I have a function that creates a data.frame.
I have been using:
g <- function(compareA,compareB) {
for (i in 1:1000) {
ttr <- t.test(compareA, compareA, var.equal = TRUE)
tt_pvalues[i] <- ttr$p.value
}
name_tag <- paste(nameA, nameB, sep = "_Vs_")
tt_titles <- data.frame(name_tag, tt_titles)
# character vector which I want to add to a list
ALL_pvalues <- data.frame(tt_pvalues, ALL_pvalues)
# adding a numeric vector of values to a larger data.frame
}
Would cbind
be better here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种方法可以按列将数据“添加或附加”到 data.frame,另一种方法可以按行附加数据。假设
tag
是 data.frame,并且tt_titles
是一个与“tag”具有相同长度的向量,那么其中任何一个都可以工作:或者:
现在让我们假设我们有两个具有相同column.names的data.frames:
There are two methods that would "add or append" data to a data.frame by columns and one that would append by rows. Assuming
tag
is the data.frame, andtt_titles
is a vector of the same length that 'tag' has rows, then either of these would work:Or:
Now let's assume that we have instead two data.frames with the same column.names: