Question 1

What is the median of the first column using the car dataset

data(cars)
median(cars$speed)
## [1] 15

Question 2

What is the maximum of daily close price for BTC in the data?

install.packages(“jsonlite”)

library(jsonlite)

url <- "https://min-api.cryptocompare.com/data/v2/histoday?fsym=BTC&tsym=USD&limit=10"

btc_data_raw <- fromJSON(url)

# Extract the actual data frame 
btc_data <- btc_data_raw$Data$Data

# View the first few rows 
head(btc_data)
##         time     high      low     open volumefrom   volumeto    close
## 1 1771632000 68686.92 67528.59 67997.02   11686.08  796953224 67965.05
## 2 1771718400 68233.91 67170.64 67965.05   11615.92  786667937 67626.88
## 3 1771804800 67663.82 63879.72 67626.88   42373.83 2766008869 64642.48
## 4 1771891200 64996.35 62551.85 64642.48   45607.54 2906212703 64069.84
## 5 1771977600 70005.48 63922.45 64069.84   55809.16 3753044531 67998.99
## 6 1772064000 68867.59 66508.93 67998.99   44886.39 3038274772 67498.16
##   conversionType conversionSymbol
## 1         direct                 
## 2         direct                 
## 3         direct                 
## 4         direct                 
## 5         direct                 
## 6         direct
# Calculate maximum daily close price
max_close <- max(btc_data$close, na.rm = TRUE)

# Print result
max_close
## [1] 68915.1

Question 3

Title: Do People use Social Media More During Winter?

Research Questions

1. Is search interest for Instagram higher in winter than summer?

2. Is there a seasonal pattern in social media search behavior?

3. Do colder months show consistently higher engagement levels?

Rename the columns so it’s easier to read

colnames(trend_data) <- c("date", "hits")

trend_data$date <- as.Date(trend_data$date)

trend_data$hits <- as.numeric(trend_data$hits)

Create a month variable/column in the data

trend_data$month <- format(trend_data$date, "%m")

Using those months, categorize them into seasons.

trend_data$season <- ifelse(trend_data$month %in% c("12","01","02"), "Winter",
                     ifelse(trend_data$month %in% c("03","04","05"), "Spring",
                     ifelse(trend_data$month %in% c("06","07","08"), "Summer",
                            "Fall")))

Compare the seasons using the mean

season_avg <- aggregate(hits ~ season, data = trend_data, mean)

season_avg
##   season     hits
## 1   Fall 54.29231
## 2 Spring 55.07576
## 3 Summer 56.81818
## 4 Winter 54.87692

The data shows the mean is the highest for summer, then spring, then winter, then fall.

Create a graph to show the difference visually.

bp <- barplot(season_avg$hits,
              names.arg = season_avg$season,
              main = "Average Instagram Search Interest by Season",
              xlab = "Season",
              ylab = "Average Search Interest",
              col = c("lightblue","lightgreen","orange","tan"),
              ylim = c(min(season_avg$hits) - 2,
                       max(season_avg$hits) + 2))

text(bp,
     season_avg$hits,
     round(season_avg$hits, 1),
     pos = 3)

Since the y values are so close together, I zoomed in so you can see the difference in the seasons. As shown, summer is the highest with fall in the lowest.