[R] matrix -> delete last row -> list

Zander, Joscha joscha.zander at roche.com
Fri Jul 3 16:33:32 CEST 2015


Good day R-community,

i just wondered if it is a bug or a feature...

When i have a matrix "mat" with one column and i delete the last row with

mat <- mat[-nrow(mat),] the result is a list.

So my next call mat[10,] will throw an "wrong dimension" error.
The proper call must be:

mat <- as.matrix(mat[-nrow(mat),])

So is this desired behavior or a bug?

I use R-version 2.15.3, but reconstructed this behavior in 3.2.0 as well.

greetings

-- 
 *Joscha Zander*

Roche Diagnostics GmbH
DXRDDD..6164
Sandhofer Strasse 116
68305 Mannheim / Germany

mailto:joscha.zander at roche.com <joscha.zander at roche.com>

 *Roche Diagnostics GmbH*
Sandhofer Straße 116; D‑68305 Mannheim; Telefon +49‑621‑759‑0;
Telefax +49‑621‑759‑2890
Sitz der Gesellschaft: Mannheim - Registergericht: AG Mannheim HRB 3962 -
Geschäftsführung: Dr. Ursula Redeker, Sprecherin; Edgar Vieth -
Aufsichtsratsvorsitzender: Dr. Severin Schwan

 *Confidentiality Note*
This message is intended only for the use of the named recipient(s) and may
contain confidential and/or privileged information. If you are not the
intended recipient, please contact the sender and delete the message. Any
unauthorized use of the information contained in this message is prohibited.

	[[alternative HTML version deleted]]



More information about the R-help mailing list