Hi, Keith,

Sorry for the delay in replying. I figured out what's going on here finally
but the fix isn't pretty.

There are 2 problems here. First, R's unlist() will drop NULL list elements,
and RBloomberg works by unlisting, then reshaping, the data it gets. If
there are NULLs, then when you unlist() you get a shorter list than you
should, so when you put this data into a matrix, data frame or zoo it's the
wrong size. However, RBloomberg is also miscalculating the number of date
columns in the returned data, so it's also trying to reshape the data into
the wrong number of columns even after the NULL issue is resolved.

For now, you can try to paste/source the following code into R AFTER you
have loaded RBloomberg, and this will redefine 2 functions to fix these
issues. This has been tested only minimally, and it is likely this is going
to break other things so please test your own data and use this with care.
If you can run this code in its own R session so other requests don't use
these hacked functions, that would be safer.

Code is here:
http://dpaste.de/3fOV/

Click on "view raw" to get raw text for copying.

Basically in as.matrix I am capping the number of date columns at 1:
nc <- length(cols) + ifelse(ndat > 0, 1, 0)

instead of
nc <- length(cols) + ndat

And in replaceBloombergErrors I added some code which unlists and puts in
NAs where the NULLs used to be.

I'm going to add this as a test case to the latest version of RBloomberg and
look into what's going on more carefully, so hopefully there should be a
permanent fix when the new version comes out in the near future.

If you get errors whilst using this, please send me a minimal test case.

Regards,
Ana



On Thu, Jul 9, 2009 at 1:05 AM, Keith Sabol <ksabol@dsaco.com> wrote:

> Essentially, I'm trying to re-create the data displayed Bloomberg's QRMD
> function.  When I run the following I get the error below:
>
>
>
> blpGetData(conn,c("X 4 Corp"), c("VOLUME","LAST_PRICE"),
> ,start=as.chron(14432.375),end=as.chron(14433.55), barsize=0)
>
>                    VOLUME LAST_PRICE
>
> (07/08/09 10:15:01) 150000 150000.000
>
> (07/08/09 11:05:01) 350000    123.026
>
> Warning message:
>
> In matrix(vec, nrow = nr, ncol = nc) :
>
>  data length [11] is not a sub-multiple or multiple of the number of
> rows [2]
>
>
>
>
>
> When I run the data request to return the "raw" data I get:
>
>
>
>
>
> blpGetData(conn,"X 4 Corp", c("VOLUME","LAST_PRICE"),
> ,start=as.chron(14432.375),end=as.chron(14433.55),
> barsize=0,retval="raw")
>
> [[1]]
>
> [[1]][[1]]
>
> [[1]][[1]][[1]]
>
> An object of class "COMDate"
>
> [1] 40001.64
>
>
>
> [[1]][[1]][[2]]
>
> An object of class "COMDate"
>
> [1] 40002.42
>
>
>
> [[1]][[1]][[3]]
>
> An object of class "COMDate"
>
> [1] 40002.43
>
>
>
> [[1]][[1]][[4]]
>
> An object of class "COMDate"
>
> [1] 40002.46
>
>
>
>
>
>
>
> [[2]]
>
> [[2]][[1]]
>
> [[2]][[1]][[1]]
>
> NULL
>
>
>
> [[2]][[1]][[2]]
>
> [1] 150000
>
>
>
> [[2]][[1]][[3]]
>
> [1] 350000
>
>
>
> [[2]][[1]][[4]]
>
> [1] 150000
>
>
>
>
>
>
>
> [[3]]
>
> [[3]][[1]]
>
> [[3]][[1]][[1]]
>
> [1] 123.026
>
>
>
> [[3]][[1]][[2]]
>
> [1] 118.107
>
>
>
> [[3]][[1]][[3]]
>
> [1] 118.475
>
>
>
> [[3]][[1]][[4]]
>
> [1] 118.75
>
>
>
>
>
> Coercions to "zoo" or "matrix" fail because of the NULL that is
> returned. Does anyone know how to get around this?
>
>
>
> Thanks in advance!
>
>
>
>
>
>
>
> Keith Sabol
>
>
>
> Email Disclosure Notice
> This message (including any attachments) is for the ad...{{dropped:12}}

