3
With the data set I have the columns C1(year),C2(states), C3(weight), and C4(value). I’d like to do the weighted average (C4) with (C3), per state(C2) per year(C1).
dados <- data.frame(c1 = c(rep(1996:2003, 4)), c2 = c(rep('rs', 8), rep('sc', 8)),
c3 = 1:32, c4 = 32:1)
dados
c1 c2 c3 c4
1 1996 rs 1 32
2 1997 rs 2 31
3 1998 rs 3 30
4 1999 rs 4 29
5 2000 rs 5 28
6 2001 rs 6 27
7 2002 rs 7 26
8 2003 rs 8 25
9 1996 sc 9 24
10 1997 sc 10 23
11 1998 sc 11 22
12 1999 sc 12 21
13 2000 sc 13 20
14 2001 sc 14 19
15 2002 sc 15 18
16 2003 sc 16 17
17 1996 rs 17 16
18 1997 rs 18 15
19 1998 rs 19 14
20 1999 rs 20 13
21 2000 rs 21 12
22 2001 rs 22 11
23 2002 rs 23 10
24 2003 rs 24 9
25 1996 sc 25 8
26 1997 sc 26 7
27 1998 sc 27 6
28 1999 sc 28 5
29 2000 sc 29 4
30 2001 sc 30 3
31 2002 sc 31 2
32 2003 sc 32 1
>
That’s right! Thank you Daniel.
– Everton Toledo