#install.packages("wbstats")
library(wbstats)
meta <- wb_cache()
names(meta)
## [1] "countries" "indicators" "sources" "topics"
## [5] "regions" "income_levels" "lending_types" "languages"
meta$topics
## # A tibble: 21 × 3
## topic_id topic topic_desc
## <dbl> <chr> <chr>
## 1 1 Agriculture & Rural Development "For the 70 percent of the world's …
## 2 2 Aid Effectiveness "Aid effectiveness is the impact th…
## 3 3 Economy & Growth "Economic growth is central to econ…
## 4 4 Education "Education is one of the most power…
## 5 5 Energy & Mining "The world economy needs ever-incre…
## 6 6 Environment "Natural and man-made environmental…
## 7 7 Financial Sector "An economy's financial markets are…
## 8 8 Health "Improving health is central to the…
## 9 9 Infrastructure "Infrastructure helps determine the…
## 10 10 Social Protection & Labor "The supply of labor available in a…
## # ℹ 11 more rows
Question 5
library(quantmod)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
getSymbols(c("NVDA","TSLA"), source = "oanda")
## [1] "NVDA" "TSLA"
getSymbols(c("NVDA", "TSLA"), source = "yahoo")
## [1] "NVDA" "TSLA"
getSymbols(c("NVDA", "TSLA"), source = "FRED")
## [1] "NVDA" "TSLA"
tail(TSLA,10)
## TSLA.Open TSLA.High TSLA.Low TSLA.Close TSLA.Volume TSLA.Adjusted
## 2025-01-28 396.91 400.59 386.50 398.09 48910700 398.09
## 2025-01-29 395.21 398.59 384.48 389.10 68033600 389.10
## 2025-01-30 410.78 412.50 384.41 400.28 98092900 400.28
## 2025-01-31 401.53 419.99 401.34 404.60 83568200 404.60
## 2025-02-03 386.68 389.17 374.36 383.68 93732100 383.68
## 2025-02-04 382.63 394.00 381.40 392.21 57072200 392.21
## 2025-02-05 387.51 388.39 375.53 378.17 57223300 378.17
## 2025-02-06 373.03 375.40 363.18 374.32 77918200 374.32
## 2025-02-07 370.19 380.55 360.34 361.62 70298300 361.62
## 2025-02-10 356.21 362.70 350.51 350.73 77514900 350.73
Question 6
getSymbols("MSFT", src="yahoo",from = "2024-10-01", to = "2025-02-01")
## [1] "MSFT"
head(MSFT)
## MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2024-10-01 428.45 428.48 418.81 420.69 19092900 419.8496
## 2024-10-02 422.58 422.82 416.71 417.13 16582300 416.2967
## 2024-10-03 417.63 419.55 414.29 416.54 13686400 415.7079
## 2024-10-04 418.24 419.75 414.97 416.06 19169700 415.2289
## 2024-10-07 416.00 417.11 409.00 409.54 20919800 408.7219
## 2024-10-08 410.90 415.66 408.17 414.71 19229300 413.8816
Question 7
nrow(MSFT)
## [1] 84
Question 9
pacman::p_load(httr, jsonlite, rvest)
#install.packages("pageviews")
library(pageviews)
microsoft_views <- article_pageviews(
project = "en.wikipedia",
article = "Microsoft",
start = "2024100100",
end = "2025013123",
user_type = "all"
)
nrow(microsoft_views)
## [1] 123
ncol(microsoft_views)
## [1] 8
Question 10
views30000 <- subset(microsoft_views, views > 30000)
head(views30000)
## project language article access agent granularity date
## 43 wikipedia en Microsoft all-access all-agents daily 2024-11-12
## views
## 43 539386
Question 11
nrow(MSFT)
## [1] 84
nrow(microsoft_views)
## [1] 123