How to append smaller DataFrame to another DataFrame in R [duplicate]

谁说胖子不能爱 提交于 2019-12-13 08:08:25

问题


I have a single DataFrame that needs to be sent to a Quality Test API that should return another DataFrame.

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.

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?


回答1:


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.


来源:https://stackoverflow.com/questions/42229019/how-to-append-smaller-dataframe-to-another-dataframe-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!