Re: [R] as.matrix strangeness

From: Adrian Duffner <duffnera_at_googlemail.com>
Date: Fri, 15 Apr 2011 11:53:49 +0200

Hallo Michael,

check ?matrix and compare to as.matrix.
as.matrix does not provide a ncol argument. To get a 2 by 2 matrix use

matrix(a, ncol=2)

Regards
Adrian

Am 15.04.2011 11:42, schrieb Michael Bach:
> Dear R users,
>
> I presume there is something foul with system:
>
> a<- c(1,2,3,4)
> as.matrix(a, ncol=2)
>
> Output:
>
> [,1]
> [1,] 1
> [2,] 2
> [3,] 3
> [4,] 4
>
> The vignette for as.matrix says nrow (ncol) will be deduced from length
> and ncol (nrow). It does not work even when I additionally specify
> nrow=2. It behaves as if I had not given the ncol argument. Any hints
> on what might be borked up here?
>
> R.Version()$ver
> [1] "R version 2.10.1 (2009-12-14)"
>
> Thanks in advance,
> Michael Bach
>
> ______________________________________________
> 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.



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 15 Apr 2011 - 10:20:51 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 15 Apr 2011 - 11:20:33 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