**From:** Ted Harding (*Ted.Harding@nessie.mcc.ac.uk*)

**Date:** Sat 29 May 2004 - 02:33:52 EST

**Next message:**Dan Kehler: "[R] Negative binomial glm and dispersion"**Previous message:**Thomas Petzoldt: "Re: [R] How to insert a bitmap in a grph device"**In reply to:**Brian Davenhall: "[R] Generate a sequence of random integer values"**Next in thread:**Ted Harding: "RE: [R] Generate a sequence of random integer values"**Reply:**Ted Harding: "RE: [R] Generate a sequence of random integer values"

Message-id: <XFMail.040528173352.Ted.Harding@nessie.mcc.ac.uk>

On 28-May-04 Brian Davenhall wrote:

*> 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.
*

(1:100)[sort(runif(100),index.return=TRUE)$ix]

37 99 22 66 12 36 90 48 55 45 98 59 92 20 46 23 2 74

80 5 63 27 56 60 51 76 39 87 19 96 29 15 18 100 52 3

70 8 67 42 43 57 91 21 25 78 41 1 34 68 77 9 72 73

11 89 83 94 65 13 14 81 24 58 35 44 10 79 50 49 6 28

17 33 4 71 82 31 75 30 85 93 26 69 38 84 32 54 64 53

88 61 86 97 7 62 95 47 16 40

but there may be a slicker way ...

Ted.

--------------------------------------------------------------------

E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk>

Fax-to-email: +44 (0)870 167 1972

Date: 28-May-04 Time: 17:33:52

------------------------------ XFMail ------------------------------

______________________________________________

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

**Next message:**Dan Kehler: "[R] Negative binomial glm and dispersion"**Previous message:**Thomas Petzoldt: "Re: [R] How to insert a bitmap in a grph device"**In reply to:**Brian Davenhall: "[R] Generate a sequence of random integer values"**Next in thread:**Ted Harding: "RE: [R] Generate a sequence of random integer values"**Reply:**Ted Harding: "RE: [R] Generate a sequence of random integer values"

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