Re: [R] To preserve the class "Matrix"

From: Shubha Vishwanath Karanth <shubhak_at_ambaresearch.com>
Date: Tue, 06 May 2008 20:51:46 +0530

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}}



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 Tue 06 May 2008 - 16:56:10 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 Wed 07 May 2008 - 02:30:35 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