Skip to content

row.names are dropped when extracting one column ?

3 messages · ryszard.czerminski@pharma.novartis.com, Marc Schwartz, Brian Ripley

#
Apparently row names are dropped when I extract
single column from a data frame. Why this behaviour ?
[1] 324
[1] 0

Best regards,

Ryszard
#
On Tue, 2004-03-02 at 11:59, ryszard.czerminski at pharma.novartis.com
wrote:
Please see R-FAQ 7.7:

"Why do my matrices lose dimensions?"

HTH,

Marc Schwartz
#
On Tue, 2 Mar 2004 ryszard.czerminski at pharma.novartis.com wrote:

            
Why are you converting a subsetted data frame to a matrix?  df[, 1:2] is a 
data frame, and df[, 1:1] is a single column (most likely a vector). The 
latter is not going to have row names, but it might have names.  It 
happens that in S the row names are not copied across as names.

row.names applies to a data frame, and not to a matrix, strictly.