keep row names into data

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

keep row names into data

jacksonmrodrigues@gmail.com
This post has NOT been accepted by the mailing list yet.
Hi,

I am calling my csv data with 37 columns and 16 rows into R. However I really need to keep coloumns names as well as row names.
Columns names is easy to keep using the command below. But how to keep row names?  

data<-read.csv("mydata", header=TRUE)

My spreadsheet is like:
                  A B C D E ...
Jhon         1  3 6 9 8
Kelly         2  3 4 6 9
Audrey    3  5 6 9 7
...

In this case I need students names.
Thanks anyone.
Reply | Threaded
Open this post in threaded view
|

Re: keep row names into data

arun kirshna


Hi,
Try:
dat1<- read.csv("mydata.csv",sep="\t",row.names=1)  #sep could be different in your case.
 dat1
#       A B C D E
#Jhon   1 3 6 9 8
#Kelly  2 3 4 6 9
#Audrey 3 5 6 9 7
A.K.



Hi,

I am calling my csv data with 37 columns and 16 rows into R. However I really need to keep coloumns names as well as row names.
Columns names is easy to keep using the command below. But how to keep row names?  

data<-read.csv("mydata", header=TRUE)

My spreadsheet is like:
                  A B C D E ...
Jhon         1  3 6 9 8
Kelly         2  3 4 6 9
Audrey    3  5 6 9 7
...

In this case I need students names.
Thanks anyone.

______________________________________________
[hidden email] 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.