Re: [R] Extracting "row.names"

From: Erik Iverson <iverson_at_biostat.wisc.edu>
Date: Mon, 23 Jun 2008 13:21:55 -0500

row.names is a function that takes a data.frame as an argument. So how about

 > row.names(data)

?

As an aside, 'data' is not the best choice for a variable name in R, since there is a function called 'data' that will get overridden if you do this ...

Patrick Richardson wrote:
> List,
>
> I'm trying to extract the row names of a table I have read into R.
>
>> data <- read.table("mesodata.txt", header=TRUE, row.names=1)
>
> When I try to extract them using,
>
>> names <- data$row.names
>
> I get,
>
>> names
> NULL
>
> I've tried changing to a matrix, data frame, etc. and still get "NULL".
> I've checked ?row.names as well as help on extracting part of an object,
> etc. and unless I'm missing something obvious (likely), I can't figure out
> how to extract them.
>
> BACKGROUND
> I want to extract the row names (which are basically gene id's) as well as
> some other columns (which I can do successfully) and "cbind" them into
> another data frame (which I can also do successfully). I just can't get the
> row names extracted (Assigned) to an seperate object.
>
> Any suggestions would be appreciated.
>
> Many Thanks,
>
> Patrick
>
>
>
>> sessionInfo()
> R version 2.7.0 (2008-04-22)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> States.1252;LC_MONETARY=English_United
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>



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 Mon 23 Jun 2008 - 18:55:32 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 Tue 24 Jun 2008 - 00:31:09 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