Hello again, let say I have following data-frame:

> Dat <- data.frame(c(rep(c("A", "B"), each = 4), "C", "C", "C"),
c(rep(1:4, 2), 1, 2, 3), 11:21)
> colnames(Dat) <- c("X1", "X2", "X3")
> Dat
   X1 X2 X3
1   A  1 11
2   A  2 12
3   A  3 13
4   A  4 14
5   B  1 15
6   B  2 16
7   B  3 17
8   B  4 18
9   C  1 19
10  C  2 20
11  C  3 21


Now I want to put that data-frame in the following form:

> Dat1 <- rbind(c(11,12,13,14), c(15,16,17,18), c(19,20,21, NA));
colnames(Dat1) <- c(1,2,3,4); rownames(Dat1) <- c("A", "B", "C")
> Dat1
   1  2  3  4
A 11 12 13 14
B 15 16 17 18
C 19 20 21 NA


Basically, 'Dat' is the melted form of 'Dat1'

Can somebody point me any R function for doing that?

Thanks for your help.

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to