How to store something not simple in a vector?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to store something not simple in a vector?

Martin Møller Skarbiniks Pedersen
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

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to store something not simple in a vector?

Martin Møller Skarbiniks Pedersen
> I am trying to create a vector to store objects create with gmp::as.bigq().
[...]

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

I got a solution now. If I use a list instead then everything works.

Regards
Martin M. S. Pedersen

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.