[datatable-help] there is no package called ‘xts’

Michael Nelson michael.nelson at sydney.edu.au
Wed Apr 24 02:41:33 CEST 2013


>From the help for data.table::last

 If x is a data.table, the last row as a one row data.table. Otherwise, whatever xts::last returns.


calling lapply(.SD, last) will call last on each column in .SD. Columns within a data.table aren't  data.tables thus `xts::last` is called.  xts is on the suggests list for data.table, 

you could use

install.packages('data.table, dependencies = 'Suggests')

or manually installed xts.

OR

frame[, last(.SD), by = id]

would work without needing xts

as would 

frame[, .SD[.N], by = id]

or without having to construct .SD (which is time consuming)

frame[frame[, .I[.N],by = id]$V1]

or 

setkey(frame, id)

frame[unique(id), mult = 'last']

________________________________________
From: datatable-help-bounces at lists.r-forge.r-project.org [datatable-help-bounces at lists.r-forge.r-project.org] on behalf of Sam Steingold [sds at gnu.org]
Sent: Wednesday, 24 April 2013 7:57 AM
To: datatable-help at lists.r-forge.r-project.org
Subject: [datatable-help] there is no package called ‘xts’

Hi,
I got this:

> dt <- frame[, lapply(.SD, last) ,by=id]
Finding groups (bysameorder=TRUE) ... done in 0.126secs. bysameorder=TRUE and o__ is length 0
Optimized j from 'lapply(.SD, last)' to 'list(last(country), last(language), last(browser), last(platform), last(uatype), last(behavior))'
Starting dogroups ... Error in loadNamespace(name) : there is no package called ‘xts’
Calls: [ -> [.data.table -> last -> :: -> getExportedValue -> asNamespace -> getNamespace -> tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
>

the help for last does mention xts, but I don't have it installed.
do I need to?

--
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.10 (quantal) X 11.0.11300000
http://www.childpsy.net/ http://ffii.org http://think-israel.org
http://mideasttruth.com http://memri.org http://camera.org
Ernqvat guvf ivbyngrf QZPN.
_______________________________________________
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


More information about the datatable-help mailing list