This question already has an answer here:
I have a data.frame that looks like this:
abun biomass size_cm
1 4 2351.85 35
2 1 1602.74 45
3 4 2351.85 35
4 1 883.54 40
5 1 367.42 30
6 2 734.84 30
7 1 210.70 25
8 5 2939.81 35
9 2 213.36 20
10 1 883.54 40
11 1 210.70 25
12 2 154.72 18
13 1 64.98 17
14 1 106.68 20
15 1 210.70 25
And I need a function to change it to:
abun biomass size_cm
1 1 2351.85 35
2 1 2351.85 35
3 1 2351.85 35
4 1 2351.85 35
5 1 1602.74 45
6 1 2351.85 35
7 1 2351.85 35
8 1 2351.85 35
9 1 2351.85 35
10 1 883.54 40
11 1 367.42 30
12 1 734.84 30
13 1 734.84 30
14 1 210.70 25
15 1 2939.81 35
16 1 2939.81 35
17 1 2939.81 35
18 1 2939.81 35
19 1 2939.81 35
20 1 213.36 20
21 1 213.36 20
22 1 883.54 40
23 1 210.70 25
24 1 154.72 18
25 1 154.72 18
26 1 64.98 17
27 1 106.68 20
28 1 210.70 25