Last time we summarized daily temperatures and counted extreme precipitation days.
Today we’ll use the same table verbs to answer two new questions.
The main task today is learning how to break down data problems into sequences of operations with table verbs: filter(), mutate(), summarize(), arrange(), group_by(), and select().
What we’ll practice
Plan the intermediate tables before writing a long pipeline.
Filter observations, summarize groups, then calculate with the summaries.
Construct a contingency table and test for association with chisq.test().
Today’s questions
Which day would you choose for a club picnic on the Diag?
What food should we order for the picnic? Do preferences differ between groups?
Your student organization wants to hold an afternoon picnic on the Diag.
There is no tent or covered space.
Assume attendees and space are available any day from May through October. (Pretend you are here for the summer!)
Our job is to use data to pick the best day to hold the picnic.
Make a plan before opening R
Before looking at the data, pick a date that you think would be best for the picnic, and explain your initial choice. What weather would make it enjoyable or force you to cancel? Describe how you would use the weather records to evaluate your choice.
Turning your idea into an analysis
Decide what matters to the people attending the picnic.
Identify measurements that could help us evaluate it.
Decide how to compare dates using those measurements.
Perform the analysis.
Report your findings.
What can these records tell us?
tmin and tmax are the daily low and high, in Celsius.
prcp is daily precipitation, in millimeters.
These are daily measurements, not the weather during the picnic.
Two simple rules
Pick the calendar date that was rainy in the fewest of the past 30 years.
Pick the calendar date whose average temperature over those years is closest to 72°F.
We’ll work together on building each rule into a pipeline. Then you’ll propose your own rule.
Compare the same date across years
year(date), month(date), and day(date) give the year, month, and day of the month.
We’ll compare dates from May 1 through October 31.
Keep the relevant days
As we saw, the weather is changing. We’ll use the period 1996–2025 as the basis for our analysis.
Rule 1: rain in the fewest years
What do we need to do?
Decide what counts as a rainy day.
For each calendar date, count how many of the 30 years were rainy.
Sort those counts from smallest to largest, or plot them.
Mark the rainy days
For this example, call a day rainy if it has at least 1 mm of precipitation.
The new column contains TRUE, FALSE, or NA.
Is 1mm a reasonable choice?
Count rainy years for each date
sum(rainy) counts TRUE values: each contributes 1.
What went wrong?
We only used 30 years of data, but n_years is 180 in most rows. Explain what went wrong and how you would fix the code.
Keep the month and day together
The first attempt combined May 10, June 10, and so on. We need a separate group for each calendar date.
.groups = "drop" leaves the result ungrouped after the summary.
Are the counts comparable?
No rows: every calendar date has a recorded precipitation value in all 30 years.
Sort from fewest rainy years to most
August 31 and September 17 tie for the fewest rainy days.
Put the rain rule into one pipeline
We can combine the steps without saving each intermediate table.
Visualizing the result
Rule 2: an average closest to 72°F
What do we need to do?
Estimate each day’s average temperature and convert to Fahrenheit.
Average those temperatures for each calendar date across the 30 years.
Calculate how far each average is from 72°F.
Sort from smallest distance to largest.
Estimate each day’s average temperature
There is no tavg column. We’ll use the midpoint of the daily low and high.
Average the temperatures for each date
Why are some averages missing?
Each of these dates has 29 recorded temperatures. Why is its mean still NA? Explain what went wrong and how to fix it.
Calculate the mean of the recorded temperatures
mean() returns NA if any input is missing. With na.rm = TRUE, we get the mean of the 29 recorded temperatures for August 9, not all 30 years. We have not recovered the missing value.
Calculate the distance from 72°F
We use mutate() after summarize() because we need the mean for each calendar date first.
Sort from closest to farthest
Look at the dates at the top of this ranking. Did we find averages closest to 72°F? Explain what went wrong and how you would fix it.
Calculate distance in either direction
Sorting mean_temp - 72 put the coldest dates first, not the closest to 72°F.
abs() gives the absolute value: 68°F is 4 degrees away; 75°F is 3 degrees away.
Try the ranking again
This rule ignores rain and how much temperatures vary around the average.
Put the temperature rule into one pipeline
Averaging first, then taking the distance, implements the rule we chose.
Now propose your own rule
The rain rule can choose a cold date; the temperature rule can choose a wet one. Both rules only look at averages and ignore variability. Propose a rule that addresses more than one concern for this picnic. What would you calculate for each observation, and what would you summarize across years for each calendar date? Does your rule make any tradeoffs?
Build your analysis in five steps
Score each day according ot your criterion.
Group the same calendar date across years.
Summarize day, while handling missing values.
Rank the days.
In an R comment, report your recommendation.
Try your rule
Start from event_days. Write your recommendation in a comment below your code.
Define a weather-based score for each day.
Group the same calendar date across years, using month and day.
Summarize each date while handling missing values.
Rank the calendar dates.
In an R comment, report a recommended date and supporting value.
What would you recommend?
Choose a date using your rule. Give a number from your results that supports your choice. How does it compare with the two simple rules, and what would you still want to know before booking the picnic?
Would another reasonable choice change our answer?
Choose one part of your rule that another group might reasonably disagree with. Predict how changing it would affect the ranking, then rerun the analysis. Does your recommendation change? What would you now tell the club?
Two orders of operations, two questions
Both pipelines run. What question does each answer? Explain which days contribute to each mean, rather than just describing the lines of code.
What should we order for the picnic?
Would one menu suit everyone?
We have a date in mind. Now we need to choose the food.
We’ll use the survey data to inform our picnic menu choices.
Predict, then plan the comparison
Would you expect the same food to be most popular in both groups? What would you calculate to decide whether one menu would suit both? Explain what an overall ranking of food choices might leave out.
Food responses
What is most popular overall?
Sushi has 36 votes, followed by burritos with 22.
Count food choices within each group
There are more sushi votes from respondents reporting North America, but that group is much larger.
Using count()
Counting is so common that we have a verb count() for it.
Arrange counts in a contingency table
A contingency table displays counts for combinations of categorical variables.
Rows are foods; columns are birth-continent groups.
Joint distribution: food and birth continent
What fraction of respondents chose sushi and reported Asia?
Every count is divided by 98.
The Sushi / Asia entry is 10/98, or about 10.2%.
All 16 entries together sum to 1.
Marginal distribution: food alone
What fraction chose sushi, regardless of birth continent?
Add across the two continent columns for each food.
margin = 1 keeps the food rows. This is marginalizing over birth continent.
For sushi, (10 + 26)/98 = 36/98, or about 36.7%.
Conditional distribution: food within a group
Among respondents who reported Asia, what percentage chose sushi?
Our groups are in the columns, so margin = 2 divides by each column’s total.
Each column sums to 100%.
The percentages are 10/18 = 55.6% and 26/80 = 32.5%.
Without a margin, divide by the whole table’s total
Every count is divided by 98, so these are joint percentages.
For Sushi / Asia, we now have 10/98 = 10.2%, not 10/18 = 55.6%.
All 16 entries together sum to 100%, not each column separately.
What would independence mean for the menu?
Under independence, the probability of choosing each food would be the same in both birth-continent groups.
Each conditional food distribution would equal the marginal food distribution.
Let’s compare the observed counts with counts expected under independence.
Get both marginal distributions
The food proportions sum to 1, and so do the continent proportions.
These are the probabilities we estimate from the survey: for example, 36/98 for sushi and 18/98 for Asia.
Why multiply the marginals?
The fraction of respondents who reported Asia is 18/98.
Under independence, the probability of choosing sushi within that group equals the overall sushi probability, which we estimate as 36/98.
We therefore estimate the fraction who reported Asia and chose sushi as (18/98) * (36/98).
Under independence, the joint probability is the product of the two marginal probabilities.
Build the product-of-marginals table
outer() multiplies every entry in the first vector by every entry in the second.
For Sushi / Asia: (36/98) * (18/98), or about 0.067.
Convert the proportions to expected counts
Multiply every entry by the number of respondents.
For Sushi / Asia, the expected count is about 6.6.
Fractional expected counts are fine; these are averages under the independence model.
We round the display, not the values stored in expected_counts.
Compare observed and expected counts
Observed counts
Expected under independence
Does a difference rule out independence?
The observed counts differ from the counts we constructed using the product of the marginals. Does this establish that food choice and birth continent are not independent in the population? Explain your reasoning. What else would you need to know before drawing that conclusion?
How much disagreement should surprise us?
A random sample can produce unequal food percentages even when food choice and birth continent are independent.
We do not expect the observed and expected counts to match exactly.
We need to ask how often independent choices would produce disagreement at least as large as ours.
The chi-square test measures disagreement across the whole table.
Some foods have very few votes
Look at the expected count for Salad / Asia:
The expected count is about 0.37, even though we have 98 respondents overall.
The usual chi-square approximation is unreliable when many expected counts are this small.
Test for independence
Interpret the test
Sushi is the most popular choice in both groups, but its share is 55.6% in one and 32.5% in the other. The test of the full table has a p-value around 0.18. What would you recommend ordering? Use the observed choices and explain what the test does, and does not, establish.
What else do we need before ordering?
A large p-value does not establish that the groups have identical preferences.
Our class survey does not represent everyone born on either continent.
A favorite-food vote does not tell us what else someone would happily eat.
We still need attendance numbers, dietary requirements, and a budget.
Checking an analysis that runs
An answer from an AI assistant
An assistant calculates the percentage choosing sushi within each birth-continent group:
What do these percentages actually describe? Which votes were removed too soon, and how would you repair the calculation?
Count all votes before filtering
This agrees with the sushi percentages within each column of our contingency table.
What to ask while building a pipeline
Which observations should be included?
What does one row represent before and after this step?
Which columns will I need later?
What belongs in the denominator?
Does the final table answer the question we started with?
Exit question
Suppose an outdoor event must take place on a day in September through November, and can tolerate cooler weather. Describe how you would change our weather analysis. Which steps would stay the same, and why would adding November require going back to the daily data?
The following slides preserve what students submitted during class. No names or login information are included.
CLASS RECORD · QUESTION 1 · 1/3
Before looking at the data, pick a date that you think would be best for the picnic, and explain your initial choice. What weather would make it enjoyable or force you to cancel? Describe how you would use the weather records to evaluate your choice.
81 anonymous responses
Other responses46
Sep 266Late-September date chosen for mild, low-humidity conditions—neither too hot nor cold—and minimal rain. Students intend to compare historical precipitation and temperature to confirm suitability.
Sep 105Chosen because current/typical early-September weather is mild and agreeable for outdoor plans. Shared concern is canceling for rain; intention to review records for rainfall and temperature patterns.
Sep 125Favored as a post-start-of-term weekend with warm but not hot conditions and lower rainfall likelihood. Students would use historical precipitation and temperature data to validate the choice.
CLASS RECORD · QUESTION 1 · 2/3
Response themes for question 1
Sep 254Late-September Friday chosen for temperate, comfortable conditions around 70–75°F and higher attendance. Main worries are extreme rain or heat; plan to consult past precipitation and temperature data.
Aug 153Selected for late-summer weekend freedom and generally pleasant sunny conditions before fall; expectations of mild temperatures. Reasons emphasize checking historical weather to confirm suitability.
Jun 123Chosen for end-of-week convenience and lighter campus crowds; expected mild early-summer warmth. Concerns focus on rain prompting cancellation; evaluative plans include checking historical precipitation and temperatures.
CLASS RECORD · QUESTION 1 · 3/3
Response themes for question 1
Jun 203Picked to maximize attendance on a Saturday and for moderate early-summer temperatures. Main rationale is availability; students plan to consult past rainfall and temperature records to assess risk.
Sep 133Selected for a weekend day with comfortable, cooling early-fall weather and minimal scheduling conflicts; students expect pleasant temperatures and low interference from events like football.
Sep 273Chosen as a Sunday late in September for more consistent, slightly cooler fall weather and broader availability; evaluation would rely on past precipitation and daily high/low trends.
QUESTION 1 · Other responses · 1/6
Student responses
1st day of the month, the semester is coming to a close and the weather is starting to get nicer so it would be a euphoric activity to have a picnic on this day
A nice Saturday when it’s not so hot.
A Sunday picknic is the best time to have. Also, september 20th is in the peak of fall so the weather should be perfect, not too warm and not too cold.
because it is after july 4th so it will not be as crowded
Because it is my birthday, and I think it was great weather and no rain
because it is my birthday, it is great to go out
Because it's near the end of the semester. Many students have already finished the semester and it's a good time for relaxation before they go back to their home. A sunny day would work, so I would check the dataset and filter out those days with no precipitation for reference.
During May, it is not too hot but not too cold. I feel like this date would provide the best temperature, exclusing other cirucmstances like rain and wind
Early fall likely to have nice weather, only thing to look out for is rain. In the school year can't choose summer
QUESTION 1 · Other responses · 2/6
Student responses
Early june should be late enough in the year to not have cold weather, but not too hot for summer weather.
Early May is warm, but before hotter summer weather hits. It also rains less in late spring, as opposed to now when it is less hot, but fairly rainy.
Good weather
I chose June 7th. June because it is the beginning of summer and hopefully wont be as hot as July or August. I also chose sunday because hopefully people are les busy that day.
I chose this day because of the saying "April Showers bring May Flowers." Rain or other inclimate weather would make the event unenjoyable, so choosing a day mid-May would allow for the time for the April rain to stop. May is typically pretty sunny and not too hot yet.
I feel like it's a day that a lot of people will be on campus and the weather would potentially be good. I think it should be sunny and not rainy.
I like this day because it is before most midterms. It is also my most free day
I personally like the weather to be cooler. Friday is a pretty good day to meet because most people don't have many classes.
QUESTION 1 · Other responses · 3/6
Student responses
I picked this day because generally, the temperature in mid-September is very nice, between 60 and 79 degrees Fahrenheit. I picked a Friday, as people usually have less work to do then other days. Any weather that is too hot, cold, or a day with too much rain/snow would not be optimal
I select this day because the weather predicted in Ann Arbor is predicted to be sunny and warm, but not too hot. People also tend to have classes off this day.
I think a Sunday would be best because there are no classes or football games. Weather with rain would force a cancellation.
I think that June is a good month because it is nice weather but not too hot yet. Also, I think Friday is a good day because people usually are more available and more open to going to different events.
I think this day is pretty good. Late august is a really good time for vacation as the largest summer heats are slowly going away but we still do not have to worry about the cold encroaching from the november. I would say enjoyable would be a hot day but not too hot and an unjowable day is a super cold or super hot day
QUESTION 1 · Other responses · 4/6
Student responses
I think this day would have a good temperature to where it wouldn't be too hot or too cold. It also isn't very likely to rain. I would check to make sure the normal range of temperatures on this day is in the mid 70s because I think that would be good for a picnic and to make sure it doesn't normally rain around this time.
I would pick this day because most students are done with class early on Friday or don't have it at all. Also, the temperature will be good at this time in September, as it should't be too hot or cold, and the rain shouldn't be bad
I would want to hold the picnic when school is in session, so a day in September makes sense. It also tends to be cooler than August and July while still being warm. It is also on my birthday!
It is before the July the 4 th holiday, so I assume people will have a good time and also relax during the picnic, even it is a little busy it will be worthy because another holiday is coming
It is MY GOAT Messi's birthday! It is summer so the weather would be nice, and we can celebrate great football!
it is not hot and sunny
QUESTION 1 · Other responses · 5/6
Student responses
It's in the summer, which means it should be warm and there shouldn't be too much rain, leading to an enjoyable picnic with nice weather.
Its a friday so people wouldnt be too busy, the weather wouldnt be too hot like in earlier weeks or too cold like in later weeks.
its my moms birthday and it is towards the end of summer when the weather is warm enough to be outside but not too hot that its unpleasant
May doesn’t usually have a lot of rain, the temp is warm but not hot.
not a week day, not too hot in the middle of summer
Not to hot or cold for the end of sept
not too hot at the end of may, hopefully no rain
People are more likelly to be in town and Friday afternoons are normally less busy for people
Right around the start of the summer semester for recruitment. And during the summer so hopefully no rain
QUESTION 1 · Other responses · 6/6
Student responses
School has started so students will be on campus
summer, sunny, hot, no snow or rain, nice for outdoors, past records show its usually sunny and hot
The date in May won't be too hot or too cold. Also, I pick weekend so that people should be more available. If it rains, we'll have to change date.
The weather is not too hot. School has not started yet. Its during a weekend.
This is my frined's birthday
This is the date when semester starts and most students are on campus.
This will be the day least likely for it to rain.
Weather is not burning hot, everyone's back on campus after FDOC, so people have something to talk about
y
QUESTION 1 · Sep 26 · 1/1
Student responses
26
I chose this day because around this time it isn't too humid or hot and it wont be raining either
I feel like late September has the nicest weather
I would initially choose a day in late September because the weather is usually warm but not too hot. The picnic would be enjoyable with mild temperatures and no rain, but heavy rain or extreme heat could force us to cancel. I would compare past weather records for different dates to see which one usually has comfortable temperatures and the lowest chance of rain.
idk
Not too hot, not too cold. Less spring rain.
QUESTION 1 · Sep 10 · 1/1
Student responses
I think a Thursday is a great day for a picnic. Enjoyable - sun, cancel rain.
In general September should have nice weather and the temperature is amiable for outdoor picnics.
It's today, and it's nice weather.
Today, have a nice weather
Weather is really nice today, plus in general, its better to have a picnic on a cooler day, its more likely to cancel with rain
QUESTION 1 · Sep 12 · 1/1
Student responses
I picked this day because not a lot of people have plans or classes on a Friday in the afternoon. If it rains that would be hard, but its not supposed to rain on this day.
I think its best because the weather should be best and I would evaluate my choices based on whether there is a lot of rain on that date historically
It is after school has started again, and the weather will be warm, but not too hot, and not raining
Mid-September is typically cooler and less rainy than both summer and spring months.
Saturdays usually are pretty free for people and it should be still pretty warm outside, but not too hot. If it rains, it should not be on that day.
QUESTION 1 · Sep 25 · 1/1
Student responses
I chose September 25th as the date for the picnic. I did this because it is now officially fall and would likely not be too warm. Additionally, students do not usually have busy friday schedules.
I chose this because it is a Friday in September. Fridays are always a good choice, September has usually good weather and temps. I think that extreme rain would force us to cancel. Or even extreme heat or cold. I would love a semi cloudy day with no precipitation.
I chose this day because during the summer months like June through August the weather might be too hot to sit outside, but in September the weather should still be nice and temperate
In late September, its usually not too hot or not too cold. My preferred temperature is around 70 to 75 degrees Fahrenheit, and Friday sounds like a good day to have a picnic.
QUESTION 1 · Aug 15 · 1/1
Student responses
Near before fall, anticipating lower temps at this time, before it gets too crowded at diag
People are free around lunch time on Saturdays, and around that time in August has great sunny weather with little reason to cancel.
This is a Friday and during a time when the weather would be nice outside so it would be more desireable to be outside with friends. Could check historical records to check if August 15th would be suitable
QUESTION 1 · Jun 12 · 1/1
Student responses
Friday is a good day because it's the end of the week and more people can probably make it. Weather wise, in the beginning of June it is warming up but still not too hot so the weather should be pretty pleasant
I think most people don't have classes on Friday and so afternoon time will be free for most people. At June, it is hot but not too hot to make it enjoyable.However, if it was raining I would cancel it
This is the friday after most people leave, which would leave the diag mostly depopulated. A less busy event tends to yield higher satisfaction and leaves folks more focused on the picnic.
QUESTION 1 · Jun 20 · 1/1
Student responses
I picked June 20th, obviously this is dependent on what the weather is like on that Saturday, but the main reason I picked it was because it wasn't a workday isn't a Sunday for religious reasons. I would use the weather records to evaluate my choice as well
I think it is a less rainy month, and saturdays are days that more people might be free. I would want to check historical records for rainfall and temperature
satuday would maximize availability and i would expect the weather to be not too hot at this time
QUESTION 1 · Sep 13 · 1/1
Student responses
Everyone would be excited to come back to school and socialize, there wouldn't be too many conflicts on a Sunday, and the weather is generally still warm but not super hot anymore.
The weather is still good at this time but not too hot. It is also on a sunday so not to interfere with a football game.
Weather still good, no football game
QUESTION 1 · Sep 27 · 1/1
Student responses
I think a sunday would be the best choice, later in september so the weather will be more consistent and a bit cooler than it is now. I would look at precipitation from previous years and high and lows of weather to determine the best date.
It will be amazing weather as it starrts to be fall
sunday
CLASS RECORD · QUESTION 2 · 1/3
We only used 30 years of data, but `n_years` is 180 in most rows. Explain what went wrong and how you would fix the code.
81 anonymous responses
Using only day component caused error16Student notes the code only considered the day-of-month or numeric date component, not month and year, leading to incorrect counts.
Need to filter rows by year range14Student says rows should be filtered to include only the desired years (e.g., restrict to the 30-year range) so n_years isn't inflated by extra rows.
Ignored month information12Student briefly notes that months were not accounted for, implying the grouping should include months.
Counted all qualifying years across dataset10Student explains n_years is 180 because counting included every year meeting the condition across the dataset, not restricted to the 30-year window.
CLASS RECORD · QUESTION 2 · 2/3
Response themes for question 2
Grouping misses month component10Student states the code ignores month information and suggests grouping by both month and day (or including month in the grouping) to avoid collapsing different months together.
Multiple entries per year inflate count8Student points out that several records within the same year (e.g., multiple dates) are being counted separately so n_years reflects number of rows or dates rather than unique years.
Group by month and day to fix6Student explicitly recommends grouping by both month and day to prevent mixing dates across months and get correct counts.
CLASS RECORD · QUESTION 2 · 3/3
Response themes for question 2
Possible incorrect n_years calculation method5Student asks whether n_years was computed as a sum of non-missing years or otherwise miscalculated rather than counting unique years.
QUESTION 2 · Using only day component caused error · 1/2
Student responses
Data was grouped by "day" which means the date out of the month, so it's calculating the number of raining day for each day of the month, not each date out of the year.
Day was used rather than years?
grouping by day groups by the day of the month, not the day of the year since we don't take into account the month each day is in when grouping, leading to many more years of each day than we actually looked at.
Grouping by day makes each of the 6 months day of the month all combine into the data for that given day. This is not an accurate representation, and it needs to be grouped by month and day.
idk
It is combining the 1st day of each of the 6 months per year into one data point.
it is grouped by day
It is summing together all the dates where precipitation is not equal to zero
It only accounted for date, and not month and date.
QUESTION 2 · Using only day component caused error · 2/2
Student responses
Since it only grouped by day and not day and month it did just by the value of the day not actual dates
The code is wromg because it doesn't give the year or day correctly
The date only range from 1 to 30, no diffenence in diffenent months.
The group only looked at day but not month
using only day component
You only used the day component
You're grouping just by day, not by both day and month.
QUESTION 2 · Need to filter rows by year range · 1/2
Student responses
.
I think that filtering methods is not correct
I would create a filter
Maybe .groups is wrong. I'm not 100% sure because maybe I just havent seen it.
need to filter by row
Need to filter rows
The units must have gotten mixed up because it was grouping by day only which would mix up the months so we would have to group them separately
we conunt years in to different units
We didn't filter out the years before 1995 in this command, so it took the data from all 180 years in the table
QUESTION 2 · Need to filter rows by year range · 2/2
Student responses
We didn't select only the date from 1996 to 2026.
We didnt filter out the data before the year 1996 so we are getting 180 years not 30
We do not filter the selected month
We woulg use 180 years of data or view the datta weri carefllu
You don't filter it to look at only the last 30 years meaning it will take all 180 years
QUESTION 2 · Ignored month information · 1/2
Student responses
check for the days of rainy, instead of summarizing years
Currently the years is being calculated by the sum , need to have filtered.
Grouping by day causes us to lose monthly information, and the data is aggregated for the 31 days of a month rather than per month
It included each date by month as well.
it is because it is counting the number of weeks?
multiple entries could've inflated
only day was used, not seperated by months. would filter by row
The 180 comes from the number of days in the range.
The group by is dropped which left less rows than we had
QUESTION 2 · Ignored month information · 2/2
Student responses
theres multiple entries
We didn't account for months.
Years is being counted in days in the year instead of labeling the year itself. Not sure where the error is.
QUESTION 2 · Counted all qualifying years across dataset · 1/2
Student responses
1
Because the data is grouping by day and not years, but then the quote is requiring to summarize by n_years.
Because we counted all of the years that there reached that precipitation benchmark of >= 1, so it is listed at 180 for each row
don't know
I think a large chunk of the data was not sorted correctly
It counted the years where it rained excluding the filter
It has overcounted by 6 times as much so it is using thr erong units
Need to filter more thoroughly by group by
No idea
QUESTION 2 · Counted all qualifying years across dataset · 2/2
Student responses
We exttracted from May to October, so if we group by each day, there will be 6 months that are extracted each year. Since we used 30 years, we end up getting 60 x 3 = 180 rows of data
group by month and day, and make sure grouping is correct
I'm not sure maybe the fact there were 6 months includede somehow
it is counting some months as years
It is counting some months as years, we didn't factor in units
It's counting some months as years
The code did not split the data by month. To fix the code, we could separate the data by month for each day in each year, which would give us n_years of 30
There is no consideration by month. As a solution, I would group by both month and days instead.
We checked rainy days per year rather than summarizing by year properly, which is fixed across years.
We grouped by days but it also grouped by month. So we need to group by month and date
QUESTION 2 · Multiple entries per year inflate count · 1/1
Student responses
Because we are grouping by day, which for 6 month, 6*30=180
Double couting years as it group by month and day and not years
I think maybe there were multple enitries per day
multiple dates within the same year
The error is that the way year was calculated counted the number of days each year
The value of n_years is based on precipitation values, meaning that each year contributes precipiation, not just 1 year.
There is some sort of a mistake with multiplicity
We used groupby day, which created 'duplicate' years
QUESTION 2 · Group by month and day to fix · 1/1
Student responses
Grouped the data by just day, instead of day and month.
It uses the wrong unit, so we need to fix the unit.
The code grouped only by the day number, so it combined the same numbered day from all six months and created 180 observations. I would fix it by using group_by(month, day) so each calendar date is counted separately.
The data is grouped by day, but it does not take into account the months. For example, data from the first day in each month is all grouped together, and so on. To fix this, group by month and day.
unsure
y
QUESTION 2 · Possible incorrect n_years calculation method · 1/1
Student responses
did you set the n_year as the sum of all the years that weren't NA?
I think the error is that the sum of the n_years was calculated at an overall 30 years but not for each year?
In the code you have n_years as a sum of the prcp which I think is why it gave 180 instead of 30.
sum years is not calculating correctly
The line where n_years is created is looking at the wrong variable
CLASS RECORD · QUESTION 3 · 1/2
Each of these dates has 29 recorded temperatures. Why is its mean still `NA`? Explain what went wrong and how to fix it.
82 anonymous responses
Missing data points present43Students state the mean is NA because one or more temperature values for those dates are missing within the range.
Exclude or ignore missing values when computing mean12Students recommend excluding missing values or configuring the computation to omit NAs so the mean can be calculated.
Data-cleaning/NA-checking mistakes6Students point to errors in how NA filtering was written or applied (e.g., forgetting to negate is.na or insufficient cleaning).
Other responses6Responses the model could not place reliably.
CLASS RECORD · QUESTION 3 · 2/2
Response themes for question 3
Missing min or max temperature5Students specifically identify that either the minimum or maximum temperature is absent, preventing calculation of the daily mean.
Grouping with NA yields NA result4A student notes that when the grouping key or aggregated count is NA, the grouped mean computation returns NA.
Units or formatting mismatch4Students suggest the NA might stem from differing units or misformatted/incorrectly recorded temperature values rather than simple missingness.
Other responses2
QUESTION 3 · Missing data points present · 1/5
Student responses
At least one recordof each of the days grouped by has an NA.
because each date contains at least one missng temperature
Because for the recorded temperature it's missing there is an NA.
Even if one value is NA, the average cannot be computed
Every other day has 30 years, so these dates only having 29 could mean that one of the entries was missing an input, leading to a NA value, which would lead to a NA value for the mean.
I didn[t check if there's any missing data
if theres only 29 and not 30 temepratures, it means on one of the years the min or max of that day was not recorded. this would mean that the average of that value would be NA
If you have 29 actual counts and one that is NA, then the mean of all of them will be NA. Since NA + anything / anything is still NA.
In some years there may be data missing causing the entire mean to be NA
QUESTION 3 · Missing data points present · 2/5
Student responses
It is NA because we do not have all of the necessary inputs to actually get to the average. As we learned previously if you pass NA through a function the entire function will return NA
Maybe an important number or data point for these days is missing and we can't compute the mean if we don't have specific numbers.
maybe one of the values on those days is missing and therefore the calculation of the mean fails
Missing data points
missing temperature is due to instrument damage
Missing values were not dropped
One of the date temperatures was NA which made the mean calculation NA
One of these days must have been missing an entry for tmin or tmax causing the whole average for the day to be NA. So we need to drop those days.
one record of these month are recorded as NA
QUESTION 3 · Missing data points present · 3/5
Student responses
Our data range is 30 years. So if n_years is 29, that means one of the temperatures for that day is missing, resulting in the whole thing being na
since it's missing
Some of the data points are missing.
The data range is 30 years, but we only see 29 years in the data table
The mean is still NA because even if 29 of the 30 years have recorded data, just one value of NA will cause the calculation to result in NA
The mean is still NA because mean_temp was calculated from all temp_f's in the mont. If a temp_f is NA for a given day, the mean temp will also be NA.
The mean temperature is NA because there are still missing values in the individual temperature values.
The temperature was not recorded on one of the days in the 30 year period which causes the computer to average it to NA.
Their temperatures were not computed for one of the days in the 30 year stretch, so when they try to average them is returns as NA because one of the values is NA.
QUESTION 3 · Missing data points present · 4/5
Student responses
There are 29 recorded temperatures, but our data has 30 years, so one year is missing records for these dates. Use mean(temp_f, na.rm = TRUE) to compute the mean without these values.
There are days that don't have a temperature (NA) and so when we try to find the average it tries to add the NA to the mean calculation and fails.
There are missing data points for one of those days within the time range.
There is a missing data value that causes the whole mean to come up as NA, fix it by removing missing values from the table
There is missing data
There might be missing values on these days, causing NA mean temps since mean of any individual NA value leads to NA overall, a good thing to fix is to drop it
There should be 30 recorded temperatures for each of these dates instead of 29, meaning that one is N/A. We can remove the one for each of these dates that is N/A and then take the average of the new data subset.
There should be 30 recorded temperatures. This means that one of the temp_f is NA, making the mean NA. Should remove NA values.
QUESTION 3 · Missing data points present · 5/5
Student responses
there was 1 missing recorded day, it makes the mean function NA too
There was one missing data point which is NA. That means the mean can't be calculated because it will show the answer as unknown
This is because if we have one NA then if we do mean, it gives NA as a result
This most likely that there was a missing data place in either tmax tmin or both and because of this when you caculated the average for that day it resulted in a NA. Note that whenever you do any operation with NA it will always result in NA so this is mostlikely what had happened. To fix it, you would need to add logic in the mean to add on days where it was not NA
We only have the mean of the 29 responses from a specific date, not all 30 years.
We should have 30 recorded temps, since there is one NA value for each date the mean() returns NA
what went wrong was the tmax or tmins were missing, leaving NA that makes it unknowable.
While calculating the mean, you did not check for any NA values, so when it calculated the mean, if any day was missing for whatever reason than it can not calculate the mean and is left as NA.
QUESTION 3 · Exclude or ignore missing values when computing mean · 1/2
Student responses
Because there is one NA temperature in the dataset, so the mean will give NA. To fix it, use na.rm
even if there's one na, the entire mean will be na because we don't know what it is, instead when calculating the mean we can remove na
i think there were missing data points, and it didn't exclude those when calculating the mean
If contain a NA, the mean would be NA because it's unknown. We need to add "na.rm=TRUE' in the code
In the 30 year period, one of the years had NA for either tmin or tmax, causing the average temp to be NA, causing mean temp to be na. You can fix this by doing na.rm = TRUE which will ignore the na since it's just 1 value.
Its because there was a value that was NA for one year. You can add the argument that ignores NA values to fix it
maybe we do not fliter the NA raw value
One NA kills the whole mean. The solution is to remove it and take the mean of the 29 recorded temperatures.
one temperature is missing out of the 30. we need to tell it to ignore all missing values and only account for the data we have
QUESTION 3 · Exclude or ignore missing values when computing mean · 2/2
Student responses
R does not assume or drop a number for NA value. So we would have to manually decide weather to drop it or put in a value so R can compute it
The mean is still NA because mean() returns NA if even one value is missing. Adding na.rm = TRUE inside the function, like mean(temp_f, na.rm = TRUE), will calculate the average using the 29 recorded temperatures.
there are missing inputs. have r exclude it when there is no value
Maybe the NA was not cleaning from the tmin and tmax, so the functions involve NA will give NA.
Sometime must have happened where there as a NA for one day out of the 30 years and one NA will cuase the avergae to be NA as well. So we should drop an NAs
the mean is still na becuase there is no ? before the is.na
the na is not cleaning the data enough
Use is.na but forget a !
QUESTION 3 · Other responses · 1/1
Student responses
Because for mean() function, it doesn't really filter out those with NA values. Once an NA exists, then the result of the mean would be NA.
If any numbers are missing, you can't take the mean of it. You need to get rid of those dates.
is the temp still in two different measures (celsius/farenheit)?
Maybe was recording in wrong degree?
There are no different data points
These temperatures that show up as NA were recorded in Celcius
QUESTION 3 · Missing min or max temperature · 1/1
Student responses
Either the max temp or min temp is missing from this day. You will need to exclude these days from the final data set
Either the min or max might have been missing, therefore there was no way to calculate those days' mean temperature.
it is missing a max or min temp for those days so the mean returns NA
The mean is NA because one of the min or max temperatures in the original data set is NA due to a lack of data, causing the average to be NA.
They don't have a tmin or tmax, so R couldn't average them. You should go find those values
QUESTION 3 · Grouping with NA yields NA result · 1/1
Student responses
a misisng vlaue in group makes mean return NA
It still has NA responses because at some points in time the data collection tower did not collect data for one reason or another. To fix this, we'll use true and false data while only keeping dates that have a recorded temp.
The mean is NA because the formula may miss.
There must be some missing data points present in the NA so that makes it impossible to calculate the mean since not all the entries are fill
QUESTION 3 · Units or formatting mismatch · 1/1
Student responses
because of NA
I think that the mean temp could be missing from one data point or recorded differently
Some of them are missing because not all months have 30 days. In this case it can range from 28-31
The mean is still "NA" because it is trying to average over all the values, regardless of weather or not a value is "NA".
CLASS RECORD · QUESTION 4 · 1/2
Look at the dates at the top of this ranking. Did we find averages closest to 72°F? Explain what went wrong and how you would fix it.
80 anonymous responses
Use absolute differences20Points out distances can be negative and that one should take absolute values to measure closeness.
Outlier or wrong sort direction15Suggests an outlier or that the sorting direction (ascending vs descending) is incorrect and causes wrong ordering.
Brief yes/no or negation10Very short confirmation or denial without explanation.
Sign error in subtraction10Notes subtracting 72 from the mean yields signed values that emphasize farthest rather than nearest; implies taking absolute value or otherwise using magnitude would fix it.
CLASS RECORD · QUESTION 4 · 2/2
Response themes for question 4
Empty or unclear response8No meaningful reason given; response is just a placeholder or punctuation.
Temperature units misunderstood7Claims the temperatures are in a different unit (Celsius), implying the comparison to 72°F is invalid.
Wrong sorting key used6Indicates the code arranged by the wrong parameter; should sort by the distance from 72 (closest to zero) rather than the raw difference or another field.
Computation formula error4States the calculation formula itself was incorrect, causing wrong results.
QUESTION 4 · Use absolute differences · 1/3
Student responses
Absolute differences
It is arranged from lowest temperature to highest temperature, we should subract from 72 and get the absolute value if we want absolute value
Its sorted the wrong way, as it contains negative values we need to look at abs value
No, since we did temp -72, some of the values are negative (and therefore lower) but we meant to calculate the distance from 72, so we should use absolute value in our calculation
No, the absolute difference must be used.
No, the code ranked the most negative differences first, so it selected the coldest dates instead of those closest to 72°F. I would calculate the distance using abs(mean_temp - 72) and then sort from smallest to largest.
No, you need to use absolute differences
No. These are negative values. We should use abs
No. We should attach an extra absolute value.
QUESTION 4 · Use absolute differences · 2/3
Student responses
The chart is arranged by smallest value to largest, so negative values appear before any values closer to 0. To fix this, we can take the absolute value of the mean temp - 72
the distance is both negative and positive, so the furthest negative seems to the closest, when is actually the lowest away. Need to absolute value it
The lowest distances are negative, you need to take absolute value
This is recording the values furthest colder than 72 degrees because it sorts by lowest and so it starts with the lowest negative values.
Those dates are the coldest days since they are less than 72 degrees F, need to do absolute value
We are sorting by distance wrong, we need to take the absolute vlaue of distance
we did not find it, should use absolute diff
We didn't look for the lowest absolute distance (distance from 0), so the top of the ranking is numbers that are way under 72 degrees F. We should arrange by absolute value.
we found the date with the lowest average temperature, to fix this we can arrange by the absolute value of distance to find the date with the average temperature closest to
QUESTION 4 · Use absolute differences · 3/3
Student responses
We found the temperatures farthest away in the negatives from 72. We have to take the absolute value of the distance
You subtracted 72 from the mean temperature instead of the other way around
QUESTION 4 · Outlier or wrong sort direction · 1/2
Student responses
Arrange arranges from lowest to highest, so instead of getting the temperatures closest to 0, we ended up getting the temperatures that were the furthest away from 72 that were below 72
It's now from the farest to the closest, we need to add arrange(desc(distance))
no, signage issue
No, we need to arrange it from descending.
Reverse the sort order
sorting in the wrong direction
The arrange() function sorted by most distant to least distant, rather than least distant to most distant as intended. The table shows the days with the temperatures most distant from 72 on top.
The current arrange call puts negative values first. A descending arrange should be used instead to get the dates with the lowest positive dfference
The distances are sorted in ascending order instead of descending order. We have to add in the descending command to fix it.
QUESTION 4 · Outlier or wrong sort direction · 2/2
Student responses
we arranged by distance before checking absolute value so it starts with smallest/most negative values, which are the coldest temperature days in our daterange.
we arranged by distance, but its giving us the farthest distance first. we just have to arrange it in the other direction
We didnt... I think we found all of the lowest mean temps. I would maybe arrange it by smallest distance?
we found the averages farthest from 72 degrees farenheit because when we used arrange, we inputted distance which would give us the results that are the farthest from out desired value.
We found the averages furthest from 72. We need to use the arrange(desc(()) function.
Wrong order asc/desc.
QUESTION 4 · Brief yes/no or negation · 1/2
Student responses
did not find averages closest to 72F
is does not include the other data
must have used absolute distance from 72 f
No we didn't find average close to 72F
NO we didn't find data closest to 72
No, responses are not all present so we need to clean the data?
No, there are around 40s.
No, we didnt find averages closest to 72, im not exactly sure what happened, maybe a list was sorted wrong.
we should sort by absolute value
QUESTION 4 · Brief yes/no or negation · 2/2
Student responses
Yes
QUESTION 4 · Sign error in subtraction · 1/2
Student responses
arrange orders in ascending order, so these are actually the values that are furthest away from 72, so we need to use desc() to get it in the correct order.
Distance is bugged. We need to convert all neg values to positive
mean_temp - 72 calculates the values furtherest from 72, not the closest.
no this didn't end up working, i'm not sure how to fix this though
No. The temperatuers on the top rows were around 47F, which is significantly lower than the average of 72F. The arrangment was done by the distance not the temperature.
problem is at that we define distance = mean_temp - 72
Ranked by distance, which was mean temp - 72. So if you're trying to see dates with mean temp close to 72, distance should be 0
The distances are in order of furthest from 72 degrees at the top
There was an error with the sign
QUESTION 4 · Sign error in subtraction · 2/2
Student responses
those dates are the most coldest days; since they are smaller than 72. we want to find the smallest absolute value from 0
QUESTION 4 · Empty or unclear response · 1/1
Student responses
.
it put the coldest days on the top of the list because subtracting all values by 72 makes all temperatures go down. We want closest to 0.
na
No we didnt, we found the days furtherest from 72, so we have to sort it in ascending order
No, arrange returned the days the most far from 72.
We found averages furthest from 72. We need to account for the positive versus negative difference between the value and the mean and use desc()
We found the dates farthest from 72 F, arrange sorts from lowest to highest, so most negative numbers come first, fix this by adding - before distance in the arrange function
We need to put a minus sign next to distance so we can arrange it in the opposite order.
QUESTION 4 · Temperature units misunderstood · 1/1
Student responses
No distance on the top is higher
no, we ignore units
No. The averages we found do not have a mean closest to 72 degrees. I think what happened is that it is giving me a listing based off of distance which is not what I want. That tells me how far I am away
the temperatures are in celsius
There was an issue with conversion from celius to fahrenheit
We found averages that weren't in the right unit
wrong of the catagorising
QUESTION 4 · Wrong sorting key used · 1/1
Student responses
I think it ranked the dates by the furthest temperature distance from 72 degrees F instead of closest. We would just need to arrange by minimum distance.
Im not too sure on what went wrong but I wonder if it had to do with compariing the wrong termpature intervals. Like maybe we are comparing an average and not a general day or maybe vice versa?
It is sorting the distance from 72 not the temp
no, we need to calculate the distance from 72 and sort by that instead
We need to sort by smallest absolute value, not smallest value.
wrong parameter for arrange, it should be how close distance is to 0, could compute abs value of distance and go downwards
QUESTION 4 · Computation formula error · 1/1
Student responses
It should compare the distance. / remove outliers
no, have some mistake in average
Our averages were not close to 72 degrees, using absolute difference
The formula for calculation went wrong
CLASS RECORD · QUESTION 5 · 1/4
The rain rule can choose a cold date; the temperature rule can choose a wet one. Both rules only look at averages and ignore variability. Propose a rule that addresses more than one concern for this picnic. What would you calculate for each observation, and what would you summarize across years for each calendar date? Does your rule make any tradeoffs?
82 anonymous responses
Combine weather metrics into a score25Proposes computing a combined desirability score per observation that blends precipitation and temperature (e.g., sum, weighted sum, or distance from ideal), and then summarizing that score across years for each calendar date (mean or median). Acknowledges tradeoffs based on weighting between rain-‑
Other responses14Responses the model could not place reliably.
CLASS RECORD · QUESTION 5 · 2/4
Response themes for question 5
Include variability in rule10Advocates adding measures of variability (e.g., standard deviation) for temperature and/or precipitation per date across years and using those alongside means to avoid choosing dates with high variability. Notes this adds complexity and may trade off average desirability for stability.
Prioritize one metric then tiebreak9Suggests a hierarchical rule that first selects by one criterion (least precipitation or below threshold) and then breaks ties using the temperature closeness to a target value; implicitly summarizes each metric across years for dates to compare. Notes tradeoffs by privileging one factor over the其他
CLASS RECORD · QUESTION 5 · 3/4
Response themes for question 5
Non-weather scheduling concerns8Raises availability and scheduling conflicts as selection factors rather than specific weather summaries; implies different data to compute (calendar availability) and different tradeoffs unrelated to weather optimization.
Simple threshold plus proximity rule7Gives a concise numerical rule: require precipitation below a threshold and choose the date with temperature closest to a target (per-observation precipitation and temp; summarize across years with frequency of meeting threshold and average/median temperature). Mentions tradeoffs of strict filtering
CLASS RECORD · QUESTION 5 · 4/4
Response themes for question 5
Use temperature range constraints5Specifies selecting dates whose observed temperatures fall within a preferred range and precipitation below a limit, summarized by proportion of observations meeting the range and typical bounds across years.
Combine rules with frequency threshold4Proposes combining criteria such that a date must meet frequency-based conditions (e.g., less than X% rainy days) and be closest to an ideal temperature when summarized across years.
QUESTION 5 · Combine weather metrics into a score · 1/6
Student responses
A rule that could be implemented is to create a new column in our data titled good_picnic where the values would be true only if it is not a rainy day and the temperature is not cold. We need to essentially combine the two tests.
calculate temperature and distance variable filtering by both and summarize avg considering both trend across years.
Choose a day that combines both the rain rule and the temperature one. A day that has less than 1 mm or rain and is above 65 degrees F. Do this by averaging over the last 30 years
Choose days with least amount of historical rainfall (rain average below a certain threshhold). Then out of those days, choose day with average temperature closest to 72 degrees F. A potential tradeoff could be that it could choose a day with some rainfall and some temperature variability.
QUESTION 5 · Combine weather metrics into a score · 2/6
Student responses
For each calendar date, I would incorporate two rules to account for weather. Temp has to be closest to 72 degrees and rain has to be closest to 1 mm. This incorporates both the temp rule and rain rule, as this would pick the average day that had the temp closest to 72 degrees and closest to 1 mm of rain, by weighing both of these factors equally
I think I would make a formula that somehow calculates both factors and come up with a index that I can compare.
I think what we can do is make a rule that incorporates both of the previous years. What if this rule takes into account rainy years and also the temperature, so essentially if we calcualte a general average between both statistics and the lowest score is the one that moves on. Not completely sure how to make that average so that its fair but maybe the most middle. I would say the tradeoff however is that you are probably never getting the best of either choice but rather the average change both
QUESTION 5 · Combine weather metrics into a score · 3/6
Student responses
I would be concerned about proximity to a rainy day. If it was raining the day before, the ground still might be wet. To calculate this, I would make a rule that a good day for a picnic cannot be within one day of a rainy day and filter out any days that do not follow this rule.
I would calculate the average distance of temp_f to 72F and the sum of rainy days of every day. Then, compute temp_distance *rainy_days and pick the lowest
I would calculate the average for each observations and i would summarize the data across the years for each claendar. not waware of any tradeoffs
I would create a score for both temperature and precipitation and see which one has both for each observation. This is what would be summarized, yet this does make a tradeoff of one factor potentially outranking the other.
I would filter by dates that rain of 0 and temperatures that are between a certain range, like 72 to 80 F. You could try to find a way to give a weight to every rain and rank it with a score and the same thing with temp and average those together
QUESTION 5 · Combine weather metrics into a score · 4/6
Student responses
I would look for the days that have the smallest amount of rain while still being a certain temperature, as well as cloud cover if possible. For the smallest amount of rain, I would find the average rain across the years, while the temperature would be the same thing we did before. For the cloud cover I would assign a boolean value to a standard, and then average that out. It doesn't consider the day, meaning that it could happen on a Tuesday, which would be inconvenient.
I would take into account both rain and temperature. calculate the rankings for each and assign them a number with the number being their ranking, like best day for temp is 1 and same for the rain (low amount of rain gets 1), then for each day combine those numbers and then rank by lowest number, tie breaker being their weather rank
QUESTION 5 · Combine weather metrics into a score · 5/6
Student responses
I would use the similar method. However, I will add a weight score respectively for precipitation and temperature. Those who are most dry or closest to 72F would be endowed with a higher weight score. Then I will add up those two weight scores and determine the date with highest combined weight scores.
make a function have are linear combination of the rain rule and the temperature rule
Make/learn an objective function that is some linear combination of rain and temperature weighted by how much you care about either temperature/rain. Then minimize/maximize. For our variables, we could do average temp per day and total precipitation, taking medians across years as our "averaging" scheme.
Maybe a rule can be a combination of the rain rule and the temperature rule. To calculate this observation I would probably try to set weights or create some type of score. This will summarize both temp and rainy days. The tradeoffs for this is that it might weight the temp and rain differently
QUESTION 5 · Combine weather metrics into a score · 6/6
Student responses
My rule would choose days that must have the least amount of precipitation while still being relatively close to 72 degrees. Rain should be less than one mm, and temperature can fluctuate 5 degrees around 72.
My two main rules would be zero rain, or as close to zero as possible. My preferred outdoor activity temperature is 75 degrees, so as close to that as well. Averaging out the two would be smart, but rain is way more important so that will factor in more than the other.
Take a sum of each variables ranking, and the lowest sum wins.
Take the ranking of each variable and add them together, the then sort by who had the best combined ranking
temp difference/ 72 + rainy days / no of days in the months and sleect smallest number, not sur ehow we ware wieghting both factors, not standardised or equal
We can assign values to coldness and wetness on a scale of 1-5 and sum both scales
you can create a score that is the sum of the desiribility of the two inputs.
QUESTION 5 · Other responses · 1/4
Student responses
Compare the both outcomes, find the most fit day from top of each outcome, allow the matching range to be within 3 days.
consider aesthetic rating of each day/ month
For each observation, I would calculate the average temperature and mark whether the day had less than 1 mm of rain and a temperature between 65°F and 80°F. For each calendar date, I would calculate the percentage of years that met both conditions and choose the date with the highest percentage. The tradeoff is that this rule may exclude some slightly rainy or cooler days that could still be enjoyable.
I will propose a hurricane rule where it shows the lkelihood the hurricane will happen in a specific date. By summarizing the time we will get a hurricane, we can avoid that day. There exists trade off at missing the other key factors.
I would also consider other variables like sunlight, because some may want sunlight but some may not.
QUESTION 5 · Other responses · 2/4
Student responses
Is the day during the fall? Some people prefer fall picnics to summer as the leaves are a different color. A simple bool expression can be calculated for each date by comparing it to when fall starts. The tradeoffs are that fall days are cooler.
Look at past extreme rare weather conditions, including when the day is too hot to go outside although it didn't rain. I will need to calculate the max temp.
Maybe commute a new sheet and then compair wet and temp. choice the day in 72F and not raining
Maybe make some sort of matrix, with each date with a suitable rating of the :suitability: for picnics. Then we can more easily observe the good picnic days while accounting different factors. Also what if we design a rule that it has to be a famous celebrity's birthday, so no matter how cold/wet/unpleasant the weather is, people can always have some fun!
QUESTION 5 · Other responses · 3/4
Student responses
My rule could be a combination of both the heat and weather rules, or perhaps a combination of heat and wind as a rule since those are both essential factors, we can calculate for both an ideal wind speed and an ideal temperature, and we would summarize a combination metric with closeness to the parameter set as ideal for wind speed + closeness of temperature, does make some tradeoffs like feels like, humidity, etc
One rule could be the UV index outside to determine how much sunscreen is necessary or the amount of foliage and fall colors present outside.
One rule that might cover more than one concern would be overall intensity of sunlight throughout the day. Shorter days in the winter will have less sunlight (still colder), and cloudier, rainier days will also have less sunlight (even during the warmer summer months). The tradeoff of this is that this kind of data might not be as readily available.
QUESTION 5 · Other responses · 4/4
Student responses
Rule: What is the best date for this picnic if I want the picnic to occur on a hot, summer day with no rain. I would have to define what hot means in degrees and provide a range of dates. I would also have to filter out dates that on average have rain. I think the tradeoff would just be what if the picnic should happen in the fall?
The sun rule, factoring the amount of sunlight for a day, which can factor in temperature and precipitation. I would calculate average UV, time of sunshine, and average temperatures so that rainfall and potential cloudly days are already factored into this decision.
QUESTION 5 · Include variability in rule · 1/2
Student responses
A rule would ensure that the dates are not too variable, limiting varinace and ensuring trim
Also look at deviation from the mean to choose the least risky date
balance temperature, rain, and variability. choose dates with consistent mild weather. prefer dates with low eather extremes
I think I will create another column that calculates the variability; also, some students may prefer cold days and wet days, so can let them complete a survey and then pick the one that most people agree with
I think looking entirely at temp and precipitation variability after finding out the best temperature days would be a good approach. After finding the top 30 best temperature days, we should sort based on the lowest variability in those day's temperatures and precipitation measurements. This will make it less likely that we cancel the event.
I would calculate a std deviation of 5yrs and 5 degrees and then look to see if we have any dates that are within that deviation for both rules above.
include standard deviation threshold for both criteria
QUESTION 5 · Include variability in rule · 2/2
Student responses
It would be better to use the max temperature because chances are that the picnic would be during the peak temperature of the day. You should also examine the standard deviation of both the temperature and rainfall. You would want something with std dev. with 3 degrees
Then we could look at days that tend to vary the least
To address more than one concern, a rule could be to have a certain range of precipitation and range of temperatures that both have to be true in order for the date to be considered good for the picnic. Instead of only looking at averages, it would consider the variation of the values as well.
QUESTION 5 · Prioritize one metric then tiebreak · 1/2
Student responses
A rule could be to pick the week that historically has the least rain, and then pick the day with the best average weather. For each calendar date I would summarize average precipiation and average temp over the years. This rule has the tradeoff of placing rain over temperature in terms of importance, but I believe that a lack of rain is more important than the most ideal temperature for a picnic.
combine both of the rules and find a day that has less than 50% of the days rainy and is closest to an ideal temperature
Finds the days that are both closest to 72F and average less than 1mm of rain.
I would look at the 30 closest to 72 degrees, then pick the one with the lowest rain days, since temperature is probably more stable across years than rain. I would also prefer a weekend day, if the resulting day wasn't a weekend I would pick the closest weekend day.
QUESTION 5 · Prioritize one metric then tiebreak · 2/2
Student responses
I would look for a date that is rainy less than half of the last 30 years, and one that is on average at most 5 degrees off of 72 F. This trades off the extremely dry or fair weather days that fail the other metric, even if this year they happen to be the best choice
I would prioritze the temperature rather than the rain since the rain is more random and does not really have much to do with the actual day. We do know that the middle of the summer will be hotter and may and october will be a little cooler. So pick the best temp
Maybe give the ranking for both rule orderings, and add the two rankings for different days together, find the smallest sum. It's the best date combineing both rain and cold rule.
pick least rainy and then temp closest to 72
To pick the best day I would want to pick a day that has the lowest chance of rain while still having decent temperatures, so I would probably pick the day whose average temperature is at least 60 and has the least number of rainy days.
filter some days in summer, and select some sunny days
I think day of the week it would be on this year is also really important, though I'm not sure exactly how we'd write a pipeline for that. A rule I'm thinking of otherwise is average max and average min temperatures?
I want to make a rule taht the date should be a day that students are willing to spend the most time out, for example, 5 hours will be better than 3 hours. I would calculate the time and try to find a most popular week then the most popular day. my rule might make tradeoffs because the results can be really colse.
I would calculate temp and precipitation and combine them into one rule. I would do the daily max temperature and total precipitation, and make sure there's no rain and not too hot
I would combine weather metrics into days that are thursdays or fridays, balancing weather with which days of the week
look at precipitation data such as multi year mean and frequency of the dry days
QUESTION 5 · Simple threshold plus proximity rule · 1/2
Student responses
For each observation I would make sure there was less than one mm of rain, and filter the weather in a range of 69 to 80 F. Across calender years I would do this by summarizing mean temp and taking out all precipitation. But removing all precipitation hides variability—summarize mean and also variability (e.g., percent dry days and temp spread). I would be clearer about per-observation checks versus across-year summaries and specify exact statistics to report.
for me, I'd say a rainy day would be greater than 4 mm of rain and a maximum temp of about 74. I say this because using a maximum temp finds us the temp we're likely going to have during the day instead of averaging the daytime and nighttime temperature values. Then I'd combine both rules to find which days are most likely to have these in common. The rule does risk the temp not being totally accurate or a burst of rainfall in the middle of the day, but I think it's likely to select a good day.
I think a good rule would be that the rain needs to be under 1mm and the temperature needs to be with 8 points of 72 degrees
QUESTION 5 · Simple threshold plus proximity rule · 2/2
Student responses
My rule would be less than 0.1 inches of average rain and any temp within 5 degrees of 72. The tradeoff would be that no day would be the perfect fit likely.
Needs a temperature between 60 and 79 degrees and less than one mm of rain. The rule can make tradeoffs by potentially going out og the range for one to secure the other
Pick a date where the min temperature is above 68, and the max temperature is below 80, and the precipitation is below 1 mm.
prcp is below one and the temp is closest to 65
QUESTION 5 · Use temperature range constraints · 1/1
Student responses
find the date with a min and max temperature range that is closest to the threshold temp range of 68-75.average min and max temperatures for each day across the years to find the average range and then find the distance from the threshold for each average.
I think that one thing I would do is find a temperature closer to 65 degrees, so that it somewhat accounts for humidity (and therefore rainy weather), but is still nice outside for a picnic.
I would honestly start only looking at months that you are confident won't be too cold or too hot, so maybe June and September. Then from there only look at rain and look at it a lot deeper. This way we rule out the temperature factor and only focus on the rain.
I would look for a weekend day with no rain and a temperature that is between 67 and 77. There may not be a perfect day but we would manually pick the closest one.
One rule can be that we can only choose a date in June, July, or August. Those days are guaranteed to be warm and they have a low likelihood of being rainy.
QUESTION 5 · Combine rules with frequency threshold · 1/1
Student responses
If there is historical record of the UV index for each day of the past 30 years, finding days where the index is closest to around 6-7.
Maybe set a threshold for each one, where for the temperature, if the temperature reaches a minimum temp, then we can choose that and then cancel it if it is wet on that day. Then you can take the average of the entries and summarize across the years for each calendar date and choose the best date for the picnic. There would be some tradeoffs with people who might enjoy rainier weather?
The humidity rule could help descide if it is wet and warm outside, which could help rule out both a cold date and a wet data. I would caluclate the mean humitity and sort by day and month. It does have tradeoffs because we are not getting the exact temperature which could be important
what about rain temperature rule
CLASS RECORD · QUESTION 6
- Define a weather-based score for each day. - Group the same calendar date across years, using month and day. - Summarize each date while handling missing values. - Rank the calendar dates. - In an R comment, report a recommended date and supporting value.
# Recommendation:
### Define days that have least amount of rain (added across month and date)
### Out of the top 10 least rainy days, choose one with best average tempdir(
least_rainy_days <- event_days |>
mutate(avg_temp = (tmin + tmax) / 2) |>
group_by(month, day) |>
summarize(total_prcp = sum(prcp),
avg_temp_cross_years = mean(avg_temp),
.groups = "drop") |>
arrange(total_prcp) |>
head(10)
least_rainy_days |> arrange(desc(avg_temp_cross_years))
event_days |>
mutate(score = as.integer(
(tmin >12) & (tmax<30))
) |>
group_by(month, day) |>
summarize(m = mean(score)) |>
arrange(m)
# Recommendation: I would set a weight on the temp and rain and create a score
event_days |>
mutate(temp_nice = ((tmin >= 12) & (tmax <= 26))) |>
mutate(norain = (prcp == 0)) |>
group_by_(month, day) |>
summarise(
n_years = sum(!is.na(prcp)),
#Recommendation: Choose a date with a temperature between 68 and 80, and no precipitation.
Choose a date using your rule. Give a number from your results that supports your choice. How does it compare with the two simple rules, and what would you still want to know before booking the picnic?
0 anonymous responses
No responses were submitted.
CLASS RECORD · QUESTION 8
Choose one part of your rule that another group might reasonably disagree with. Predict how changing it would affect the ranking, then rerun the analysis. Does your recommendation change? What would you now tell the club?
0 anonymous responses
No responses were submitted.
CLASS RECORD · QUESTION 9
Both pipelines run. What question does each answer? Explain which days contribute to each mean, rather than just describing the lines of code.
0 anonymous responses
No responses were submitted.
CLASS RECORD · QUESTION 10
Would you expect the same food to be most popular in both groups? What would you calculate to decide whether one menu would suit both? Explain what an overall ranking of food choices might leave out.
0 anonymous responses
No responses were submitted.
CLASS RECORD · QUESTION 11 · 1/2
The observed counts differ from the counts we constructed using the product of the marginals. Does this establish that food choice and birth continent are not independent in the population? Explain your reasoning. What else would you need to know before drawing that conclusion?
74 anonymous responses
Need formal hypothesis test33Students say differences alone don't prove non-independence and that a formal statistical test (e.g., chi-square, p-value) is needed to assess significance.
Randomness and noise may explain differences13Students attribute discrepancies to randomness, noise, or small sample size rather than true dependence.
Concludes dependence without caveats9A student asserts that differing observed and expected counts indicate the variables are not independent, without mentioning uncertainty.
Need joint distribution or matching-not-by-chance evidence7Says we need to know the joint distribution or evidence that the pattern isn't due to chance before concluding dependence.
CLASS RECORD · QUESTION 11 · 2/2
Response themes for question 11
Random sampling and representativeness concerns4Students point out the sample may not be random or representative, so conclusions about the population can't be drawn.
Concern about confounding or other factors3Points out possible confounding variables or other unmeasured factors that could explain the observed differences.
Suggests data/table errors or covariance issues3Student suggests that discrepancies might arise from errors in the table or covariance-related issues rather than dependence per se.
Other responses2
QUESTION 11 · Need formal hypothesis test · 1/5
Student responses
Does not establish they are not independent. Need to run a chi squared test and actualy get a p value with a test. We need further statistical testing
I don't think it would necessarily mean that they are independent. We would need to run further testing such as a p-test
if we find that the choice are independent then there is not a correlation between the two, a test should be conduct to verify this
it can't say that those two variable are not independent, need formal test
It does not. Randomeness and noise may explain the differences. We will need a hypothesis test because drawing the conc
Just because the observed counts vary from expected count. can't say its independent because you need p-value to see how "far off" each count is and take into account random variability
No it does not. Our job is to figure out if the difference is statistically significant, or just variance / noise.
No it doesn't mean they are not independent. We need an actual hypothesis test
QUESTION 11 · Need formal hypothesis test · 2/5
Student responses
No, because the test would need to be run more than once for you to rule our independence. One survey isn't enough data to be statistically significant.
No, because there's always a bit of randomness that can lead to variation as well as possibly another factor that confounds the relationship.
No, it could be due to random chance alone that the counts done match up completely. i would like to see a p test as well to understand the statistical significance of the results we got
No, it does not establish that , you would still need more to go off of and cannot conclude if independent or dependent yet, would need stndard dev , chi square etc
No, it does not establish this. We would need to get a p-value to see if things are in fact dependent
No, the results of one survey with 98 respondents can not prove that food choice and birth continent are independent or dependent, you would need a formal test with more responses to make a conclusion
QUESTION 11 · Need formal hypothesis test · 3/5
Student responses
No, the tables would not match. There is a expected amount of variation between expected amount and observed amount. You need a formal statistical test to determine if the differences between the observed and expected amounts are statistically significant.
No, there could just be some sampling variance so the events could be independent, but the tables don't match up exactly
No, we are just looking at a sample (and getting exactly on the mark from samples is rare). So we should run a significance test of some sort to find convincing evidence
No, we have to see if that difference is statistically significant through a chi squared test/p-val test
No, we need to conduct a test to generate a p-value to see if the differences are statistically significant.
No, we would need a controlled test to establish that. Theres specific formulas for this that are not coming to mind right now
no, we would need a formal hypothesis test
No, with only this sample we cannot be sure that the factors are independent. We need multiple repeated samples and to run a test that returns a low p value.
QUESTION 11 · Need formal hypothesis test · 4/5
Student responses
No, you need to do additional calculations on the product of the counts
No. random sampling variation can cause differences and you should perform a chi-square or simulation test and check the survey’s representativeness before concluding dependence.
The counts are not expected to match perfectly. However to decide if the relation is independent or dependent, we need to do actual statistical testing
The observed counts will be different, but it is not evidence because we did not construct a t-test or other statistical test. We need to evaluate the evidence against the null hypothesis before drawing conclusions.
The tables would not match exactly even if the two variables were independent, because some variance is expected. You would need to do a statistical test to show that the two variables are independent.
There would have to be a much higher trend or correlation between food choice and continent
QUESTION 11 · Need formal hypothesis test · 5/5
Student responses
They would not match exactly as the expectation disregards noise (assumed E[epsilon] = 0). The observed will not necessarily match the expectation. I suppose we'd need a formal hypothesis test to check the sample difference.
We have a much smaller sample of people from Asia compared to north America. Also, since this is random it should be exact it just needs to be close.
We still need to perform a Chi-square independence test to know if they are independent. A mere difference won't tell.
We would need a larger sample size/one more reflective of the general population inorder to conclude that food choice and birth continent are not independent. If we keep the same sample, we would still need to run a chi-squared test to check for differences in observed/expected counts
You would need a formal hypothesis test in order to confirm indepdencen, there is a lot of randomness and variability that could be accounting for this difference since the numbers are so small.
QUESTION 11 · Randomness and noise may explain differences · 1/2
Student responses
Construct a residual plot to see if there are any confounding variables and another simulation to see if the sample is truly random and independent, chi square
I do not think that they necessarily have to match. We keep emphasizing that we are working with an extremely noisy set of data so that may contribute to it.
It does not have to exactly match the exact number to be independent. On the other hand, when it matches exactly, it does not mean it is not dependent.
no you wouldnt as we would assume some degree of randomness among the observed points.
No, because of randomness.
No, it doesn't have to be exact
No, since we are only using a small sample size, we should try another way of calculating
Not necessarily, it would depend on how much they vary from the expected, and its that's beyond reasonable variance.
The first table was counting in discrete way, where the second table is computed in continuous way. The noise may also change the results.
QUESTION 11 · Randomness and noise may explain differences · 2/2
Student responses
The sample size of survey responses isn't sufficient enough to determine that they're independent
there could be other factors in play, maybe people who take data sci classes are more into sushi. or the sample size is not big enough
there is still some variability so you cant expect them to match exactly
this does not establish that food vhoive and birth continent are not independent
QUESTION 11 · Concludes dependence without caveats · 1/2
Student responses
food choice and birth continent are not independent and would need to confirm with h tets
The differing counts suggest that food choice and birth continent are not independent in the population, because the real counts do not match the scenario where they are independent, implying that birth continent affects food choice.
This establishes that food choice is *likely* not independent of birth continent. We would have to run a separate t-test in order to see if there is a relationship between the two groups.
Ya it means it snot inedpedent. THis is because where you born can affect ur food prefernces as food you ate growing up you willbecome more accustomed to and enjoy eating more. We would need ot know unfenerecn etst
Yes
yes it does because it is standardized
Yes it does establish that they are not independent. This is because it is clear that there is a difference between them when looking at the product of marginals. However, we would need to run a t-test of some sorts to verify.
QUESTION 11 · Concludes dependence without caveats · 2/2
Student responses
Yes this establishes that the food choice and the birth content are not indpeendent in the population. We would need a formal hypothesis test to help draw this conclusuion
Yes, because the popular food choice is the same in the oberserved counts, if they were dependent they would be close to expected counts
QUESTION 11 · Need joint distribution or matching-not-by-chance evidence · 1/2
Student responses
Before drawing that conclusion, you would need to know that the variables are matching up NOT by chance
It does not establish that food choice and birth continent are not independent in the population. The expected counts are just probabilities but due to external factors the expected counts won't always match. That doesn't mean that the variable are independent. In order to know independence you would need to run tests that determine associations (p-value).
No I dont think it establishes that food choice and birth contienetn are not indpeendent, Im not entirley sure on what else we will need to know, but I think we would have to re apply the rule?
no, they can be dependent on each other, but not strictly the case. Need bigger pool of info
No. Food choice and birth continent each have their own weights that contribute to the product of the marginals, as seen by the weights they carry. I'm not sure what else would be needed.
They establish that they are independent since food preferance could be random
QUESTION 11 · Need joint distribution or matching-not-by-chance evidence · 2/2
Student responses
This does not establish that food choice and birth continent are not independent in the population because we do not know if the data satisfies the necessary assumptions, such as the normality assumption. We would need to know how the data was collected to know whether this difference establishes a lack of independence.
QUESTION 11 · Random sampling and representativeness concerns · 1/1
Student responses
I don't think that given our data, the variables are not independent because this class is technically not a random sample, so we cant generalize to the public with our class data.
No, as it is not a randomly selected dataset
No, this case it was the same, but it doesn't have to be.
No, we are doing random sampling, so the observed would have different to what we calculated
QUESTION 11 · Concern about confounding or other factors · 1/1
Student responses
It leads us towards that statement, but we don’t know if there are any potential confounding variables that could correlate them.
No. There might be other factors we did not compute in this data set that might be affecting between two choices
This does not establish that food choice and birth continent are not independent in the population. You need to run the test to understand the margins the cause it to be independent rather than dependent.
No, since the popular food choice is the same for both groups but it is not always the case.
yes, with covariance, it could be some error in the table
CLASS RECORD · QUESTION 12
Sushi is the most popular choice in both groups, but its share is 55.6% in one and 32.5% in the other. The test of the full table has a p-value around 0.18. What would you recommend ordering? Use the observed choices and explain what the test does, and does not, establish.
0 anonymous responses
No responses were submitted.
CLASS RECORD · QUESTION 13
What do these percentages actually describe? Which votes were removed too soon, and how would you repair the calculation?
0 anonymous responses
No responses were submitted.
CLASS RECORD · QUESTION 14
Suppose an outdoor event must take place on a day in September through November, and can tolerate cooler weather. Describe how you would change our weather analysis. Which steps would stay the same, and why would adding November require going back to the daily data?