Below is a reproducible example showing the problem:
openSummary <- read.table(textConnection(
"Dates dollarA numTotal
7/3/2011 52730.56 1614
7/10/2011 77709.43 1548"), header = TRUE)
openSummary$Dates <- strptime(openSummary$Dates,"%m/%d/%Y")
str(openSummary)
head(openSummary) # No problem
openSummaryDT <- data.table(openSummary)
str(openSummaryDT)
head(openSummaryDT) # An error is produced
Here is the error upon executing head(openSummaryDT)
Error in `rownames<-`(`*tmp*`, value = paste(format(rn, right = TRUE), :
length of 'dimnames' [1] not equal to array extent
please explain the error and how can I avoid it. However, it appears that i can do some operation on both data frame and data table and I get the same results.
difftime(Sys.Date(), openSummary[ ,"Dates"])
difftime(Sys.Date(), openSummaryDT[ ,Dates])
Thank you in advance