Charlie Stevens

## 
## The downloaded binary packages are in
##  /var/folders/9_/4c9yx6hj0tdfpf6r823cszk40000gn/T//RtmplZAveG/downloaded_packages
## 
## The downloaded binary packages are in
##  /var/folders/9_/4c9yx6hj0tdfpf6r823cszk40000gn/T//RtmplZAveG/downloaded_packages
## 
## The downloaded binary packages are in
##  /var/folders/9_/4c9yx6hj0tdfpf6r823cszk40000gn/T//RtmplZAveG/downloaded_packages

Question 1: True or False

Answer: True

Question 2: True or False

Answer: False

Question 3: True or False

Answer: False

Question 4: From where can we check how a package’s function works (e.g., how getSymbols() function works)? Select all that applies.

Answer: All of the above

Question 5: True or False

Answer: True

Question 6: Which option exactly return(s) the daily stock prices for Microsoft during 2024-10-01 ~ 2025-01-31 (including both end dates)?

getSymbols("MSFT", src="yahoo",from = "2024-10-01", to = "2025-02-01")
## [1] "MSFT"

Question 7: How many days of stock prices did you obtain?

nrow(MSFT)
## [1] 84

Question 8: Which time period did Microsoft’s Open prices reach the highest?

max_open_price <- max(MSFT$MSFT.Open)  # Find highest open price
max_open_date <- index(MSFT)[which.max(MSFT$MSFT.Open)]  # Find the corresponding date
print(paste("Highest Open Price:", max_open_price, "on", max_open_date))
## [1] "Highest Open Price: 451.320007324219 on 2024-12-18"

Answer: Dec 9 – Dec 18

Question 9: Try writing the R code to get another online data source of Wikipedia views data for Microsoft in English language from 2024-10-01 to 2025-01-31. Once you successfully extract this data, how many observations and variables did you get?

msft_views <- article_pageviews(
  project = "en.wikipedia",
  article = "Microsoft",
  start = "2024100100",  
  end = "2025013100",  
  user_type = "all"  
)

Answer: 123, 8

Question 10:Based on your extracted data above, how many days in total are with a Wikipedia views over 30,000?

high_views <- subset(msft_views, views > 30000) 
nrow(high_views) 
## [1] 1

Question 11:

nrow(MSFT)
## [1] 84
nrow(msft_views)
## [1] 123

Answer: False

Question 12: True or False

Answer: True