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

From: Charles C. Berry <cberry_at_tajo.ucsd.edu>
Date: Thu, 06 Nov 2008 12:34:30 -0800

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 )

instead of as.matrix( your.result )

HTH, Chuck

>
> I mean, it's not extremely a problem,
> because there are not many loops aroud it,
> but it looks somehow ugly. :(
>
> 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.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry_at_tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901

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 Thu 06 Nov 2008 - 20:37:14 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 - 01:30:22 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