| To: | "P.J.Wells" <P.J.Wells@open.ac.uk> |
|---|---|
| Subject: | Re: Concatenating random number of random length vectors |
| From: | Sundar Dorai-Raj <sundar.dorai-raj@pdf.com> |
| Date: | Thu, 27 Mar 2003 08:28:02 -0800 |
| Cc: | "S-plus list (S-plus list)" <s-news@wubios.wustl.edu> |
| Organization: | PDF Solutions, Inc. |
| References: | <2AF05AF70A86A6438445BC3AC057F498204E28@mir.open.ac.uk> |
| User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 |
P.J.Wells wrote: The following looks like it should be simple, but I can't see it -- would someone kick-start me? I have vectors sample.1, sample.2,...sample.N, where N is a random number, and length(sample.i) is also random.How do I turn these into one big vector?
Julian,
There are several ways:
`for':
# assume each vector is named `sample.i'
# where `i' is 1:N
samp <- c()
for(i in 1:N)
samp <- c(samp, get(paste("sample", i, sep = ".")))
`do.call':
# assume your N samples are in a list `samp.list'
# where length(samp.list) == N
samp <- do.call("c", samp.list)
HTH,
Sundar
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Concatenating random number of random length vectors, P.J.Wells |
|---|---|
| Next by Date: | Re: Concatenating random number of random length vectors, ripley |
| Previous by Thread: | Concatenating random number of random length vectors, P.J.Wells |
| Next by Thread: | Re: Concatenating random number of random length vectors, ripley |
| Indexes: | [Date] [Thread] [Top] [All Lists] |