I would like to submit this reproduceable example of the solution because I experienced exactly the same trouble in attempting to apply data.table functions to a data frame without the class of data.table. It took me considerable effort to figure this out on my own, because the solution on this page is buried inside the comments and those comments did not explain how to reproduce the solution.
As soon as I found out that DF2 was missing the data table class, I immediately used DT2 <- as.data.table(DF2) right after the incidence of transform() and aggregate(). In other words, I simply used the name of the object I originally believed was the data table, on both sides of the formula. For example, if it was named PuTTy_2 <- DF2, then my formula was
PuTTy_2 <- as.data.table(PuTTy_2)
I ran all available package updates, including for data.table, which did not solve my problem. Only when I tried class(DT2) vs. class(DT1) did I find out that DT2 was missing the data table class and had only the data frame class. Therefore, DF2 and DT1 would have been the appropriate abbreviations.
This seemed like the result of running DF2 <- transform(DT1, ... ) and also DF2 <- aggregate( ... , DT1). Although I did not check this directly by troubleshooting my code, I looked up transform() and aggregate() functions, and I confirmed that both those functions work exclusively with data frames.