Thanks Michael. I had written Depends in all caps in the DESCRIPTION file and assumed that calling library(data.table) within the function would override that anyway.
Greatly appreciated On 11 June 2014 05:00, <[email protected]> wrote: > Send datatable-help mailing list submissions to > [email protected] > > To subscribe or unsubscribe via the World Wide Web, visit > > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > > or, via email, send a message with subject or body 'help' to > [email protected] > > You can reach the person managing the list at > [email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of datatable-help digest..." > > > Today's Topics: > > 1. data.table error: invalid subscript type, except it isn't. > (Mikkel Grum) > 2. Re: data.table error: invalid subscript type, except it > isn't. (Michael Smith) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 10 Jun 2014 12:17:54 -0500 > From: Mikkel Grum <[email protected]> > To: [email protected] > Subject: [datatable-help] data.table error: invalid subscript type, > except it isn't. > Message-ID: > <CAPeJDOSDqfa5JqPjchw=mku_uuw0q5dl9ab2t5mbfaxkz2x...@mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > 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 > > > ------------------------------ > > Message: 2 > Date: Wed, 11 Jun 2014 09:38:28 +0800 > From: Michael Smith <[email protected]> > To: Mikkel Grum <[email protected]> > Cc: [email protected] > Subject: Re: [datatable-help] data.table error: invalid subscript > type, except it isn't. > Message-ID: <[email protected]> > Content-Type: text/plain; charset=ISO-8859-1 > > Have you imported data.table into your RAPI package? > > 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 > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > > End of datatable-help Digest, Vol 52, Issue 7 > ********************************************* -- Mikkel Grum, PhD Director, Research and Development ParqueSoft Calle 25 #127-220 Cali, Colombia cel +57 313 730 1976 website | map | email _______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
