library(tidyverse)
library(ggthemes)
tech_october <- read_csv("https://bcdanl.github.io/data/tech_stocks_2026_10.csv") |>
filter(Ticker == "MSFT" | Ticker == "META" )Classwork 16
Visualizing Time Trends
Complete the questions and submit your responses on the corresponding Brightspace page.
Complete the code in an R script and keep your brief written interpretations with it. This page contains its own setup and data definitions; no earlier classwork is required.
Setup and data
The course file contains daily stock-trading records from October 1–30, 2026. Use Microsoft and Meta to study daily trading volume, the number of shares traded during a day. The supplied code keeps these two companies. read_csv() recognizes the Date column as calendar dates automatically.
| Variable | Meaning |
|---|---|
Date |
Trading day |
Ticker |
Company identifier: MSFT = Microsoft, META = Meta |
Volume |
Number of shares traded during that trading day |
Each row represents one company’s trading record on one trading day. There are 22 observed trading days per company. Volume counts shares traded, not distinct traders or dollars. These are historical records, not current trading activity.
Filling-in-the-blank: 1. Trading activity over time
Use this supplied filter to keep Microsoft’s rows. Complete the plot so it marks each observed trading day and connects the observations in date order.
microsoft_october <- tech_october |>
filter(Ticker == "MSFT")
ggplot(data = microsoft_october,
mapping = aes(x = ____,
y = ____)) +
____(color = "grey60") +
____(color = "steelblue")Now add + geom_smooth() to the plot, using the default settings. Explain what the points, connecting line, and smooth curve each show. Why doesn’t the smooth curve tell us what trading volume will be in November?
The blanks are Date, Volume, geom_line, and geom_point.
microsoft_october <- tech_october |>
filter(Ticker == "MSFT")
ggplot(data = microsoft_october,
mapping = aes(x = Date,
y = Volume)) +
geom_line(color = "grey60") +
geom_point(color = "steelblue")Each point records how many Microsoft shares traded on one observed trading day. On October 1, for example, the point represents 19,731,882 shares. The horizontal axis shows calendar dates and the vertical axis shows shares traded, not dollars or distinct traders. The grey line connects the 22 observations in date order. Its segments do not add observations for weekends or other dates missing from the file.
Add the default smooth curve:
ggplot(data = microsoft_october,
mapping = aes(x = Date,
y = Volume)) +
geom_line(color = "grey60") +
geom_point(color = "steelblue") +
geom_smooth()geom_smooth() estimates the average pattern across the observed dates, making broad movement easier to see without following every daily fluctuation. The curve need not pass through the points. Its shaded ribbon shows uncertainty around the fitted average, rather than the full spread of daily volumes. This curve summarizes the October observations; it supplies neither November observations nor a forecast of November trading volume.
