-1

I am trying to merge two large data frames with bind_rows.

df<-bind_rows(df1,df2)

The result is that R cannot allocate a vector of n size.

I want to do this because I need to arrange and export it in a txt.

df<-df%>%
arrange(date,id)

What can i do?

user438383
  • 5,716
  • 8
  • 28
  • 43
Amc
  • 131
  • 8
  • Please always [research](https://meta.stackoverflow.com/q/261592/1422451) before posting a new question. Asking a question on Stack Overflow should be the *last* step in your process for finding an answer... – Parfait May 27 '23 at 18:58

1 Answers1

1

The first question to ask is how big are the 2 data frames? How many rows do they have? If it is something reasonable, one simple thing you could try is to use rbind from base R, which I expect to have less overhead than bind_rows, but I'm not sure about that.

If your data are too big to be handled by data frames, you should look into using the data.table data type or an approach where the data is stored on disk instead of memory. See for example the following reference: https://rdpeng.github.io/RProgDA/working-with-large-datasets.html

BigFinger
  • 1,033
  • 6
  • 7