I am working with pretty large dataframes, with as an extreme a dataframe with about 300.000 rows and 1.500 variables. Because of that, when working on those dataframes, I sometimes get the error:
Error: cannot allocate vector of size x.x Gb
Mostly this means I have to split up my code into smaller steps, or have to change my approach altogether.
At the moment I am doing several selections and left_join
's which look something like this:
#Subsetting the main dataframe
df2 <- select(df1, matchcode, x1, x2, x3)
#Joining variables from a third dataframe
df2 <- df2 %>% left_join(select(df3, matchcode, y1, y2, y3), by="matchcode")
The selection part goes perfectly. The odd thing however, is that I am now getting these errors when using left_join
where the amount which cannot be allocated is very small:
Error: cannot allocate vector of size 2.6 Mb
Error: cannot allocate vector of size 4.0 Mb
Error: cannot allocate vector of size 2.6 Mb
Are there other issues which could result in these errors that I am not aware of, or is there a fault in my code?