[R] Numeric, 2 ??? as a result of marix???

Gabor Grothendieck ggrothendieck at gmail.com
Sat Aug 29 13:31:07 CEST 2009


g does not appear to be a matrix, as described.   Its more
likely a data frame.   If that is the case then as.matrix(g)
will create a matrix from it.

Also depending on what you want to do ?unlist, ?t or ?c
may be of help.  Also try str(g) and dput(g) to see
internals of object as they seem not to be what you
believe them to be.

On Fri, Aug 28, 2009 at 6:15 PM, Wolfgang
Polasek<wolfgang.polasek at gmail.com> wrote:
> Strange things are going on in R, if you reshape a matrix in R:
>> g=gretldata[1:2,]
>> g
>   Empfang   Versand  Transit  Inland Ausland    SumS
> 1 787844.0 1307176.6 223395.4 1474726 16199.1 3809341
> 2 421473.1  306445.4 448801.2 1779402 14445.6 2970567
>> dim(g)
> [1] 2 6
>> as.vector(g)
>   Empfang   Versand  Transit  Inland Ausland    SumS
> 1 787844.0 1307176.6 223395.4 1474726 16199.1 3809341
> 2 421473.1  306445.4 448801.2 1779402 14445.6 2970567
>> gg=matrix(as.vector(g),nrow=1,byrow=TRUE)
>> gg
>     [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
> [1,] Numeric,2 Numeric,2 Numeric,2 Numeric,2 Numeric,2 Numeric,2
>>
>  Help please,the docu on thids is lousy!!!.
> Wolfgang
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>




More information about the R-help mailing list