[R] error message: .Random.seed is not an integer vector but

(Ted Harding) Ted.Harding at manchester.ac.uk
Thu Jul 23 18:13:58 CEST 2009


On 23-Jul-09 15:30:05, Jim Bouldin wrote:
> I'm trying to run this simple random sample procedure and keep
> getting the error message shown. I don't understand this; I've
> Thanks.
> 
>> x = as.vector(c(1:12));x
>  [1]  1  2  3  4  5  6  7  8  9 10 11 12
>> mode(x)
> [1] "numeric"
>> sample(x, 3)
> Error in sample(x, 3) : 
>   .Random.seed is not an integer vector but of type 'list'
> 
> Jim Bouldin, PhD

I think this error is not arising from the code you have given above.
I get:

  x=as.vector(c(1:12))
  sample(x,3)
  # [1]  8 12  2

which is fine. '.Random.seed' should be an integer vector to start with.
See '?set.seed'. Therefore it should not be a list. Try entering

  .Random.seed

and see what you get -- when I do it it is a vector of 626 assorted
integers. Also try:

  is.vector(.Random.seed)

and, if that is not TRUE, try

  str(.Random.seed)
  typeof(.Random.seed)

If .Random.seed turns out to be a list, then something has gone
seriously wrong somewhere. It may be that somwehere in your code
there is a command that meddles with .Random.seed (or perhaps it
was saved, in .Rdata, from a previous session where something
went wrong). Or, worst scenario, your R installation is broken ...

And, while I'm at it, your "x=as.vector(c(1:12))" is overkill!
Simply

  x <- (1:12) ; sample(x,3)

should be enough, or even

  sample((1:12),3)

since (1:12) is a vector (of integers).

Hoping this helps,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 23-Jul-09                                       Time: 17:13:55
------------------------------ XFMail ------------------------------




More information about the R-help mailing list