[R] row.name in data.frame
Nordlund, Dan
NordlDJ at dshs.wa.gov
Tue Oct 5 22:39:24 CEST 2004
Does this do what you want:
mydata <-read.table('mydata.txt',header=TRUE, row.names=1)
see ?read.table
Daniel Nordlund
Research and Data Analysis
Washington State Department of Social and Health Services
P.O. Box 45204
Olympia, WA 98504-5204
-----Original Message-----
From: S Peri [mailto:biocperi at yahoo.com]
Sent: Tuesday, October 05, 2004 1:03 PM
To: r-help at stat.math.ethz.ch
Subject: [R] row.name in data.frame
Hi Group,
I have a table with column names and row names.
Species A B C D E F G
Human 1 2 3 4 1 0 3
Rat 0 2 3 3 2 1 2
I read this tab delim. text file into R like the
following:
> mydata <-read.table('mydata.txt',header=TRUE)
> mydata
Species A B C D
1 Human 1 2 3 2
2 Rat 0 2 5 2
3 Cat 9 2 4 1
Why am I getting 1,2,3 row names even after declaring
heder = TRUE. I tried declaring row.names = NULL,
however it is not accepting it and expects a vector
with some names. I wanted Human, Rat and Cat as my row
names. I wanted my data frame look like:
Species A B C D
Human 1 2 3 2
Rat 0 2 5 2
Cat 9 2 4 1
I apologise for asking a lame question and this
question might have been posted several times. I could
not find an answer.
Thanks
P
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list