Closed victord3 closed 2 years ago
You only want to print the lowest once -- after the for loop has completed. Not inside the for loop which executes every time a lower number is found.
You actually have a similar problem with #3. You are calculating the mean each time you go through the for loop. Yes, the answer is correct at the end because only the last calculation is saved. But, this is highly inefficient -- you are doing 366 mean calculations instead of 1! You only want to calculate the mean once.
Also, line 32: Just set meanTemp to NULL here -- to indicate there would not be a value at this point in the script. Technically, the line does not even need to be there if you do this calculation in the right place...
two issues: 1) Your if-else structure does not capture precip of exactly 0.1. 2) Minor issue -- line 55 should be coded to better match the pattern of the other conditions, which use greater than (this would also fix #1).
I believe I corrected them.
Almost....: cat(lowestTempDate,"had the lowest temp of", lowTemps[i], "\n")
After the for loop, i will be the value it had on the last cycle. That means this code will always print the low temp for the last day in the column.
Updated! Forgot to change it after I put it outside the loop.
Alright, I'll give it ro you!
Completed 1-10