[R] How to store something not simple in a vector?

Martin Møller Skarbiniks Pedersen tr@xp|@yer @end|ng |rom gm@||@com
Mon Jan 27 01:32:53 CET 2020


Hi,

  Sorry for the HTML version in the buttom of this email.
I don't think it is possible to post using gmail without a
html-version in the end.

Anyway to my problem:

I am trying to create a vector to store objects create with gmp::as.bigq().

My first attempt:
library(gmp)
V <- vector("bigq", 100)

My second attempt after understand that I probably need to
examine a bigq with typeof()

library(gmp)
V <- vector(typeof(as.bigq(1)), 100) # typeof(as.bigq(1)) is raw
V[[100]] <- as.bigq(1,2)

With the error message:
Error in V[[100]] <- as.bigq(1, 2) :
  more elements supplied than there are to replace

And now I understand that bigq is stored as raw-bytes and it
is has a length more than 1. Actually:
length(as.raw(as.bitq(1,2))
[1] 16

Please advise.
Thanks a lot.

/Martin M. S. Pedersen



More information about the R-help mailing list