I am taking a data.table:
DT <- data.table(num=c(1,4,6,7,8,12,13, 15), let=rep(c("A","B"), each=4))
An then I have the following result:
> sapply(DT, class)
num let
"numeric" "character"
Which is ok.
Then, adding a line:
DT<-rbind(DT, as.list(c(8, "B")))
And then:
> sapply(DT, class)
num let
"character" "character"
I find this vicious that R changed the first column type to character and did not expect it ... I can change the column to numeric afterwards but it's painfull if I have to check after every insert.
Is there's a way to add line without this drawback?