I want to use := operator from data.table without loading data.table. For example for the following data.table, I want to add another column called error
:
DT <- data.table::data.table(station = rep(1:1,52560), mod = rnorm(1*52560),obs = rnorm(1*52560))
If I do the following everything goes well, however, I am puzzled how it worked without referring to package data.table (the data.table library is not loaded)?!!
DT[ , `:=`(error = mod - obs)]
How can I rewrite the above line using data.table::::=
?!!
Data. table is an extension of data. frame package in R. It is widely used for fast aggregation of large datasets, low latency add/update/remove of columns, quicker ordered joins, and a fast file reader. The syntax for data.
The R package DT provides an R interface to the JavaScript library DataTables. R data objects (matrices or data frames) can be displayed as tables on HTML pages, and DataTables provides filtering, pagination, sorting, and many other features in the tables.
On the Data tab, click What-If Analysis > Data Table (in the Data Tools group or Forecast group of Excel 2016).
Not sure I understand correctly, but regarding :
I am going to use this in another package and preferably I want not to load data.table. – newbie
I am importing the package, I have no other choice since data.table will not work if I do not import. Would importing alone take care of this? – newbie
Yes Import data.table rather than Depend on it from your package. You may have tried that and it didn't work because of this common issue. See solution here :
Using data.table package inside my own package
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With