[datatable-help] data.table error: invalid subscript type, except it isn't.

Mikkel Grum mikkel at scarab-solutions.com
Tue Jun 10 19:17:54 CEST 2014


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

-- 
Mikkel Grum, PhD
Director, Research and Development

ParqueSoft  Calle 25 #127-220  Cali, Colombia
cel +57 313 730 1976
website | map | email


More information about the datatable-help mailing list