victord3 / My_Project

Non-Credit R Class
0 stars 0 forks source link

1-10 #4

Closed victord3 closed 2 years ago

victord3 commented 2 years ago

Completed 1-10

belinskyc commented 2 years ago

5:

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.

3

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...

4:

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).

victord3 commented 2 years ago

I believe I corrected them.

belinskyc commented 2 years ago

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.

victord3 commented 2 years ago

Updated! Forgot to change it after I put it outside the loop.

belinskyc commented 2 years ago

Alright, I'll give it ro you!