Change rows and columns

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Mat
Reply | Threaded
Open this post in threaded view
|

Change rows and columns

Mat
Hello together,

how can i change rows and columns in R?

I have a data.frame like this one:

     1st round | 2nd round
1   1:2               2:2
2   2:3               1:0
3   0:0               1:1

and now i want to change for further processing my rows and columns.

                             1       2       3
1st round           1:2    2:3    0:0
2nd round          2:2   1:0    1:1

can you help me?

Thanks.

Mat
Reply | Threaded
Open this post in threaded view
|

Re: Change rows and columns

arun kirshna
This post has NOT been accepted by the mailing list yet.
Hi,

If `dat1` is the dataset
res<-as.data.frame(t(dat1))
colnames(res)<- gsub("[V]","",colnames(res))
 res
 #              1    2    3
# 1st round   1:2  2:3  0:0
 #2nd round   2:2  1:0  1:1
A.K.
Mat
Reply | Threaded
Open this post in threaded view
|

Re: Change rows and columns

Mat
thx, that worked perfekt, but is there any way to convert my Number 1 row
#              1    2    3
up as column description?
Reply | Threaded
Open this post in threaded view
|

Re: Change rows and columns

John Kane
Please reply with context to the list. Most R-help readers do not use nabble.

I don't quite understand your question but do you mean something like ?names?

John Kane
Kingston ON Canada


> -----Original Message-----
> From: [hidden email]
> Sent: Tue, 29 Jan 2013 07:41:21 -0800 (PST)
> To: [hidden email]
> Subject: Re: [R] Change rows and columns
>
> thx, that worked perfekt, but is there any way to convert my Number 1 row
> #              1    2    3
> up as column description?
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Change-rows-and-columns-tp4656965p4656969.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [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.

____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!

______________________________________________
[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.