I have to combine two large data frames df1 and df2 to one data frame in R. The rbind() function is computationally expensive. The Stack() function is preferable to use for large datasets, so I am using the Stack() function to stack the data frames one over the other to form one data frame like the following:
library(Stack)
a = Stack (df1, df2)
However, I get the following error:
1: ‘V1’: coerced to ordered factor
2: ‘V1’: factor levels expanded: check levels/codes!
3: ‘V13’: coerced to ordered factor
4: ‘V13’: factor levels expanded: check levels/codes!
5: ‘V14’: coerced to ordered factor
6: ‘V14’: factor levels expanded: check levels/codes!
7: ‘V15’: coerced to ordered factor
8: ‘V15’: factor levels expanded: check levels/codes!
9: ‘V16’: factor levels expanded: check levels/codes!
The class of both df1 and df2 data.frame and both the dataframes have the same column names and number of columns. Why am I still getting this error?
errororwarning message? - akrunV1/V13/V14/V15are factors in both data frames, but with different range of values. When combined, the factor levels have to be expanded to accommodate values from both data frames. Also, as per akrun's comment, these should be warning messages rather than errors. - Z.Linlibrary(data.table); setDT(df1); setDT(df2); rbind(df1, df2)for performance? - Hugh