Hope it helps this time:)

### Package reshape, function melt and cast
### Read table
dummy <- read.table(textConnection("State Months Bedroom
1    xxx    Jan       1
2    xxx    Jan       2
3    xxx    Jan       1
4    yyy    Jan       1
5    yyy    Jan       2
6    yyy    Jan       1
7    zzz    Jan       3
8    zzz    Jan       1
9    zzz    Jan       2
10   xxx    Feb       3
11   xxx    Feb       4
12   xxx    Feb       2
13   yyy    Feb       1
14   yyy    Feb       2
15   yyy    Feb       1
16   zzz    Feb       2
17   zzz    Feb       3
18   zzz    Feb       3 "))

## Melt
melt.dummy <- melt.data.frame(dummy,id.vars=c("State","Bedroom"),
measure.vars="Months")

## Cast
cast(melt.dummy, State + Bedroom ~ value,length)

-----
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-required-to-melt-a-data-frame-tp2229633p2230729.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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