Hi everyone, I have this kind of rainfall dataset: Year Month Day Amount 1 1950 1 1 0.0 2 1950 1 2 35.5 3 1950 1 3 17.8 4 1950 1 4 24.5 5 1950 1 5 12.3 6 1950 1 6 11.5 7 1950 1 7 5.7 8 1950 1 8 13.2 9 1950 1 9 11.3 10 1950 1 10 14.7 11 1950 1 11 11.9 12 1950 1 12 17.5 13 1950 1 13 8.1 14 1950 1 14 0.4 15 1950 1 15 0.0 16 1950 1 16 19.5 17 1950 1 17 10.7 18 1950 1 18 0.5 19 1950 1 19 12.7 20 1950 1 20 6.3
I want to set as rain for Amount> 0 and not rain for Amount = 0. I want to replace the Amount>0 with 1 and Amount equal to zero with 0. Then I want to count how many rain in that particular month in that year. Anyone can help me? This is what I want: Year Month Day Amount 1 1950 1 1 0 2 1950 1 2 1 3 1950 1 3 1 4 1950 1 4 1 5 1950 1 5 1 6 1950 1 6 1 7 1950 1 7 1 8 1950 1 8 1 9 1950 1 9 1 10 1950 1 10 1 11 1950 1 11 1 12 1950 1 12 1 13 1950 1 13 1 14 1950 1 14 1 15 1950 1 15 1 16 1950 1 16 1 17 1950 1 17 1 18 1950 1 18 1 19 1950 1 19 1 20 1950 1 20 1 Then become like this: | | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | | 1950 | 17 | 6 | 23 | 20 | 19 | 9 | 17 | 23 | 18 | 20 | 20 | 17 | | 1951 | 23 | 19 | 20 | 20 | 19 | 11 | 16 | 20 | 22 | 25 | 25 | 16 | | 1952 | 15 | 21 | 30 | 24 | 23 | 20 | 16 | 19 | 20 | 19 | 21 | 15 | Thanks. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.