0

I am was working with a dataframe, which I had to convert into a data table for manipulation. When I try to rbind() the 2 data tables, I get the following warning message

require(data.table)
table1 <- data.table(x)
table2 <- data.table(y)

## I did a lot of processing here for these 2 tables, then wanted to bind them

bt=rbind(table1,table2)
Warning message:
In rbindlist(allargs) : NAs introduced by coercion

I found a previous question here about this issue, it is a bug in R

The issue I am having is that I am working with a massive dataset, and I cannot notice whether new NA values are being added to the dataframe. (why would any NA values be added anyway?)

I tried to get around the problem by converting the data tables into dataframes before binding them.

table1 <- data.frame(table1)
table2 <- data.frame(table2)
bt=rbind(table1,table2)

I no longer get the error, but I am really worried about my data! were any NA values added? or is my data staying the same by doing this trick? I happy to continue with my data in the data.frame from.

Thanks,

Community
  • 1
  • 1
Error404
  • 6,959
  • 16
  • 45
  • 58
  • Who knows without any data. Have you tried to recreate this problem with a small sample of your data? BTW to `rbind` `data.table`'s together use `rbindlist` – Simon O'Hanlon Sep 13 '13 at 14:11
  • I'd also try `all( sapply( x , class ) == sapply( y , class ) )`, if you get `FALSE` you know you have a type mis-match between at least one of your columns. – Simon O'Hanlon Sep 13 '13 at 14:12
  • Without seeing your data we can't help much. Can you add the output of `str(table1)` and `str(table2)`. I assume it is because you have a column of numbers with the same name as a column of characters... – Justin Sep 13 '13 at 14:12
  • 2
    The bug you mention was apparently fixed: which version of `data.table` are you using? What is the output of `sessionInfo()`? – Vincent Zoonekynd Sep 13 '13 at 14:19
  • 1
    I've voted to close as dup. The strange thing is you referred to it in your question. We were careful to update that question when it was fixed, and put the update at the top of the answer so it was easily visible. If it's still a problem though, then please be clear that you upgraded and what the new problem is. – Matt Dowle Sep 13 '13 at 15:28

0 Answers0