RE: [R] Generate a sequence of random integer values

About this list Date view Thread view Subject view Author view Attachment view

From: Duncan Mackay (Duncan.Mackay@flinders.edu.au)
Date: Fri 28 May 2004 - 12:10:58 EST


Message-id: <003b01c44459$042f66d0$71e66081@duncanlt>

Hello,
Have a look at the "sample" command.

E.g.
> sample(20)
 [1] 3 2 18 6 10 5 9 20 19 13 8 15 17 7 4 14 11 1 12 16

Duncan

*****************************************
Dr. Duncan Mackay
School of Biological Sciences
Flinders University
GPO Box 2100
Adelaide
S.A. 5001
AUSTRALIA

Ph (08) 8201 2627 FAX (08) 8201 3015

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Brian Davenhall
Sent: Friday, 28 May 2004 10:24 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Generate a sequence of random integer values

I'm trying to generate a sequence of random integer values. I've tried
to combine the random (r) and the sequence (seq) functions but this
approach does not work. For example, if I use the following command:

> a <- seq(1:100)
> a
  [1] 1 2 3 4 5 6 7 8 9 etc.

This is a good start, but what I really want is something that would
look like this instead

 [1] 3 96 45 67 8 24 99 63 8, etc.

where the integer numbers between 1 and 100 are randomly chosen.

Any help would be great, I've found workarounds in other stat packages,
but would prefer to do this in R.

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:13 EST