Here is my data.
dat<-read.table(text=" MP1 MP2 MP3 N1 N2 N3 WP1 WP2 WP3
A A A Y Y Y 10 11 11
A B A Y Y Y 10 11 11
B B A Y Y Y 10 10 11
A B A Y Y Y 11 11 10
B B A Y Y Y 10 10 11
B B A N Y Y 11 10 10
B C A Y Y Y 11 11 11
C C B Y Y N 10 11 10
B C B Y Y Y 11 11 11
B C B Y N Y 10 11 11
",header=TRUE)
I want to get this table. Indeed I want to get three columns instead of nine columns. These columns are named as follows:
MP N WP
A Y 10
A Y 10
B Y 10
A Y 11
B Y 10
B N 11
B Y 11
C Y 10
B Y 11
B Y 10
A Y 11
B Y 11
B Y 10
B Y 11
B Y 10
B Y 10
C Y 11
C Y 11
C Y 11
C N 11
A Y 11
A Y 11
A Y 11
A Y 10
A Y 11
A Y 10
A Y 11
B N 10
B Y 11
B Y 11
I have tried this:
dat1 <- data.frame(MP=unlist(dat, use.names = FALSE))
But, not sure why it does not work. I also used
dat2 <- data.frame(MP = c(dat[,"MP"], dat[,"N"],dat[,WP])))