[R] Extracting "row.names"
richard.pearson at postgrad.manchester.ac.uk
Mon Jun 23 21:50:02 CEST 2008
As a further aside, names is also not the best choice for a variable name for the same reason.
Erik Iverson wrote:
> row.names is a function that takes a data.frame as an argument. So how
> > 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:
>> 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,
>> 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
>> how to extract them.
>> 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,
>> R version 2.7.0 (2008-04-22) i386-pc-mingw32
>> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
>> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>> attached base packages:
>>  stats graphics grDevices utils datasets methods base
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
Richard D. Pearson richard.pearson at postgrad.manchester.ac.uk
School of Computer Science, http://www.cs.man.ac.uk/~pearsonr
University of Manchester, Tel: +44 161 275 6178
Oxford Road, Mob: +44 7971 221181
Manchester M13 9PL, UK. Fax: +44 161 275 6204
More information about the R-help