gpt4 book ai didi

r - 如何在 R 中向数据框添加行?

转载 作者:行者123 更新时间:2023-12-03 04:48:18 24 4
gpt4 key购买 nike

在 R 中,一旦数据框已初始化,如何向数据框添加新行?

到目前为止我有这个:

df <- data.frame("hi", "bye")
names(df) <- c("hello", "goodbye")

#I am trying to add "hola" and "ciao" as a new row
de <- data.frame("hola", "ciao")

merge(df, de) # Adds to the same row as new columns

# Unfortunately, I couldn't find an rbind() solution that wouldn't give me an error

如有任何帮助,我们将不胜感激

最佳答案

让我们简单一点:

df[nrow(df) + 1,] = c("v1","v2")

关于r - 如何在 R 中向数据框添加行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28467068/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com