Re: [R] replicate and as.matrix: different behaviour between batch and non-batch mode

From: Oliver Bandel <oliver_at_first.in-berlin.de>
Date: Fri, 07 Nov 2008 01:07:41 +0100

Hi,

Zitat von "Charles C. Berry" <cberry_at_tajo.ucsd.edu>:

> On Thu, 6 Nov 2008, Oliver Bandel wrote:
>
> > Hello Charles,
> >
>
> [snip]
>
> >> dim( as.matrix( replicate(10, sample(x, 3) ) ) )
> > [1] 3 10
> >> dim( as.matrix( replicate(10, sample(x, 2) ) ) )
> > [1] 2 10
> >> dim( as.matrix( replicate(10, sample(x, 1) ) ) )
> > [1] 10 1
> >>
> > =====================
> >
> >
> > So, the behaviour is the same...
> > ...but is not really that fine. :(
> >
> > ...how could I avoid the necessity of the transposition
> > of the matrix in the case of only one sample?
>
>
> use
> matrix( your.result , nc = n.replicates )
>
> or
>
> dim( your.result ) <- c( n.samples, n.replicates )
[...]

Aaaah, OK!

Yes, using dim() makes sense.

Good hint!

Thanks!

Ciao,

   Oliver



R-help_at_r-project.org mailing list
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. Received on Fri 07 Nov 2008 - 00:13:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 07 Nov 2008 - 00:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive