I have a data set like this:
df<-read.table (text=" House1 House2 House3 House 4
9 4 8 3
8 6 3 3
9 9 6 5
8 8 3 9
9 5 5 10
4 3 8 6
3 6 10 3
9 8 6 8
3 9 10 5
7 8 2 4
", header=TRUE)
The values 2,4,3 and 1.5 are multiplied in each row. 2 goes to House1, 4 goes to House2, 3 goes to column3 and 1. goes to House4. This gives me the following table:
House1 House2 House3 House 4
18 16 24 4.5
16 24 9 4.5
18 36 18 7.5
16 32 9 13.5
18 20 15 15
8 12 24 9
6 24 30 4.5
18 32 18 12
6 36 30 7.5
14 32 6 6
is there a simple code to do it?