I am fairly new to R and am currently working with a fairly large dataframe. Basically what I am trying to do is turn something like this:
Year Sample Species Catch
1 2016 1 a 9
2 2016 1 b 5
3 2016 1 c 13
4 2016 1 d 2
5 2016 1 e 4
6 2016 1 f 13
7 2016 2 a 7
8 2016 2 c 5
9 2016 2 f 6
10 2016 2 g 2
into this:
Year Sample Species Catch
1 2016 1 a 9
2 2016 1 b 5
3 2016 1 c 13
4 2016 1 d 2
5 2016 1 e 4
6 2016 1 f 13
7 2016 1 g 0
8 2016 1 h 0
9 2016 1 i 0
10 2016 1 j 0
11 2016 1 k 0
12 2016 2 a 7
13 2016 2 b 0
14 2016 2 c 5
15 2016 2 d 0
16 2016 2 e 0
17 2016 2 f 6
18 2016 2 g 2
19 2016 2 h 0
20 2016 2 i 0
21 2016 2 j 0
22 2016 2 k 0
That is, there is a set number of species (a through k), and where there is no record of that species in the "Sample" I want to have a record showing 0.
Thanks!