如何在R中将较小的DataFrame附加到另一个DataFrame [英] How to append smaller DataFrame to another DataFrame in R
本文介绍了如何在R中将较小的DataFrame附加到另一个DataFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个DataFrame,需要将其发送到质量测试API,该API应该返回另一个DataFrame。
I have a single DataFrame that needs to be sent to a Quality Test API that should return another DataFrame.
但是不幸的是,API没有接受DataFrame作为整个操作,因此我将它逐行切片并将其发送给API。
But unfortunately the API is not accepting the DataFrame as a whole and hence I am slicing it row by row and sending it to the API.
因此,每个请求都得到单行DataFrame。
有人可以告诉我如何将这些单行附加到较大的数据框中吗?
Hence I am getting single row DataFrames with each request. Can someone tell me how I can keep appending these single rows to a larger Data Frame?
推荐答案
您可以使用 bind_rows
将数据帧彼此附加 dplyr
包。
You can append data frames to each other using bind_rows
from the dplyr
package.
df1 = data.frame(number = c(1, 2, 3, 4),
name=c("Alice", "Bob", "Charlie", "Donna")
df2 = data.frame(number = c(5), name=c("Eve"))
df3 = bind_rows(df1, df2) #df3 has all five rows.
这篇关于如何在R中将较小的DataFrame附加到另一个DataFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文