I have the raw data with 9 column and 197977 row:

> dummy
   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

> dim(rawdata)
[1] 197977      9

I want to do some calculation on the "State" "Months" "Bedroom". So I am
picking only three column using subset.

> subsets.dummy <- subset(dummy, select=c("State","Months","Bedroom"))
> subsets.dummy
   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       0
17   zzz    Feb       3
18   zzz    Feb       3

>From the above data. I want below table for 1,2,3,4.... Bedroom.
Ex : for 1 Bedroom, I need how may(count of 1 Bedroom) 1 Bedroom is there in
a particular state for month wise.

State  Jan Feb
 xxx   2    0
 yyy   2    2
 zzz   1    0

for 2 Bedroom :
State  Jan Feb
 xxx   1    1
 yyy   1    1
 zzz   1    0

I want to melt "subsets.dummy" data for the above requirement. To achive
this I am doing like this:
>
melt.data.frame(subsets.dummy,id.vars=c("State","Bedroom"),measure.vars="Months")
   State Bedroom variable value
1    xxx       1   Months   Jan
2    xxx       2   Months   Jan
3    xxx       1   Months   Jan
4    yyy       1   Months   Jan
5    yyy       2   Months   Jan
6    yyy       1   Months   Jan
7    zzz       3   Months   Jan
8    zzz       1   Months   Jan
9    zzz       2   Months   Jan
10   xxx       3   Months   Feb
11   xxx       4   Months   Feb
12   xxx       2   Months   Feb
13   yyy       1   Months   Feb
14   yyy       2   Months   Feb
15   yyy       1   Months   Feb
16   zzz       2   Months   Feb
17   zzz       3   Months   Feb
18   zzz       3   Months   Feb

I trying to get a new data frame for 1 bedroom using cast. But I am not able
to get the below data for 1 Bedroom using cost.

State  Jan Feb
 xxx   2    0
 yyy   2    2
 zzz   1    0

I not able to understand how to cost it.  any help will be greatly
appreciated.

Thanks & Rg
Mohan L

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