Try this: x[1,, drop = FALSE]
On Tue, Jul 21, 2009 at 1:46 PM, Vadim Ogranovich < vogranov...@jumptrading.com> wrote: > Dear R-help, > > When the result of a matrix subscription degenerates to a scalar the names > implied by the dimnames are discarded. > > > x <- matrix(0, 1, 1, dimnames=list('a', 'x')) > > ## below I expected result to have names='x', it's not > > x[1,] > [1] 0 > > ## below I expected result to have names='a', it's not > > x[,1] > [1] 0 > > This is probably a side effect of 'drop' applied to a 1*1 matrix, is there > an elegant way around? > > One possibility could be to allow the 'drop' arg in '[' to take numerical > values (in addition to bool), which would be interpreted as dimensions to > drop. > > Thanks, > Vadim > > Note: This email is for the confidential use of the named addressee(s) only > and may contain proprietary, confidential or privileged information. If you > are not the intended recipient, you are hereby notified that any review, > dissemination or copying of this email is strictly prohibited, and to please > notify the sender immediately and destroy this email and any attachments. > Email transmission cannot be guaranteed to be secure or error-free. Jump > Trading, therefore, does not make any guarantees as to the completeness or > accuracy of this email or any attachments. This email is for informational > purposes only and does not constitute a recommendation, offer, request or > solicitation of any kind to buy, sell, subscribe, redeem or perform any type > of transaction of a financial product. > > ______________________________________________ > R-help@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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ R-help@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.