[R] To preserve the class "Matrix"

Shubha Vishwanath Karanth shubhak at ambaresearch.com
Tue May 6 17:21:46 CEST 2008


Thank you very much Mark! That worked.... Just a question, ?[ does give an error to me...how do I find it?

Shubha Karanth | Amba Research
Ph +91 80 3980 8031 | Mob +91 94 4886 4510 
Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com

-----Original Message-----
From: Shubha Vishwanath Karanth 
Sent: Tuesday, May 06, 2008 8:50 PM
To: 'Mark Leeds'
Subject: RE: [R] To preserve the class "Matrix"

Thank you very much Mark! That worked.... Just a question, ?[ does give an error to me...how do I find it?

Shubha Karanth | Amba Research
Ph +91 80 3980 8031 | Mob +91 94 4886 4510 
Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com

-----Original Message-----
From: Mark Leeds [mailto:markleeds at verizon.net] 
Sent: Tuesday, May 06, 2008 8:46 PM
To: Shubha Vishwanath Karanth
Subject: RE: [R] To preserve the class "Matrix"

Hui Shubha: If I understand what you're asking, you want to use drop=FALSE
as in a[1,,drop=FALSE] That retains the dimension ( ie, the matrixness ) of
the object.


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Shubha Vishwanath Karanth
Sent: Tuesday, May 06, 2008 11:07 AM
To: r-help at stat.math.ethz.ch
Subject: [R] To preserve the class "Matrix"

Hi,

 

Suppose

a=matrix(1:9,3,3)

 

> a

     [,1] [,2] [,3]

[1,]    1    4    7

[2,]    2    5    8

[3,]    3    6    9

 

Now,

> class(a[1:2,])

[1] "matrix"

> class(a[1:3,])

[1] "matrix"

> class(a[,1:2])

[1] "matrix"

> class(a[,1:3])

[1] "matrix"

 

 

But,

> class(a[1,])

[1] "integer"

> class(a[,1])

[1] "integer"

 

Can in a general way get class(a[1,]) or class(a[,1]) to be "matrix" only?

Shubha Karanth | Amba Research

Ph +91 80 3980 8031 | Mob +91 94 4886 4510 

Bangalore * Colombo * London * New York * San Josi * Singapore *
www.ambaresearch.com

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}


This e-mail may contain confidential and/or privileged i...{{dropped:10}}



More information about the R-help mailing list