[datatable-help] data.table error: invalid subscript type, except it isn't.
Steve Lianoglou
lianoglou.steve at gene.com
Thu Jun 12 20:17:48 CEST 2014
Hi,
On Tue, Jun 10, 2014 at 6:38 PM, Michael Smith <my.r.help at gmail.com> wrote:
> Have you imported data.table into your RAPI package?
This.
You shouldn't have a line in your package that explicitly loads the
data.table package -- ie. there should be no "library(data.table)"
line in your package.
Instead you should list "data.table" in the "Imports" field in the
DESCRIPTION file of your package, then in the NAMESPACE file you
should have an "import(data.table)" line.
Once those two things are in place, everything should be feng shui.
HTH,
-steve
>
> M
>
> On 06/11/2014 01:17 AM, Mikkel Grum wrote:
>> Hello data.table useRs
>>
>> I've written a function myTable that I've included in a package I've
>> made myself (RAPI). The function calls library(data.table) and does a
>> number of things to the data using the data.table functionality. On
>> its own (cutting and pasting the code into R) the function works well,
>> but when I install the package and then try to run the function, I get
>> the following error
>>
>>> library(RAPI)
>>> myTable(11, '2014-06-09')
>> data.table 1.9.2 For help type: help("data.table")
>> Error in `[.default`(x, i) : invalid subscript type 'list'
>>
>>> sessionInfo()
>> R version 3.1.0 (2014-04-10)
>> Platform: x86_64-pc-linux-gnu (64-bit)
>>
>> locale:
>> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
>> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
>> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
>> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
>> [9] LC_ADDRESS=C LC_TELEPHONE=C
>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>
>> attached base packages:
>> [1] stats graphics grDevices utils datasets methods base
>>
>> other attached packages:
>> [1] data.table_1.9.2 RODBC_1.3-10 RAPI_1.0
>>
>> loaded via a namespace (and not attached):
>> [1] plyr_1.8.1 Rcpp_0.11.1 reshape2_1.4 stringr_0.6.2
>>
>>
>> The line that fails is
>> stopsperrow <- myData[, length(timestamp), by = list(name, house, row)]
>>
>> However, if I type the function name, myTable, and cut and paste the
>> function from the console back into the console, the command produces
>> the desired output without any hiccups! In other words the function in
>> the package is OK, but something about the environment isn't right -
>> if that's the right way to put it.
>>
>> Any ideas for where I should be looking, or what I should be trying?
>>
>> Regards
>> Mikkel
>>
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
--
Steve Lianoglou
Computational Biologist
Genentech
More information about the datatable-help
mailing list