library(wbstats)
meta <- wb_cache()
names(meta)
## [1] "countries" "indicators" "sources" "topics"
## [5] "regions" "income_levels" "lending_types" "languages"
write.csv(meta$countries, "countries.csv")
write.csv(meta$topics, "topics.csv")
wb_search("population")
## # A tibble: 3,967 × 3
## indicator_id indicator indicator_desc
## <chr> <chr> <chr>
## 1 1.0.HCount.1.90usd Poverty Headcount ($1.90 a day) The poverty hea…
## 2 1.0.HCount.2.5usd Poverty Headcount ($2.50 a day) The poverty hea…
## 3 1.0.HCount.Mid10to50 Middle Class ($10-50 a day) Headcount The poverty hea…
## 4 1.0.HCount.Ofcl Official Moderate Poverty Rate-National The poverty hea…
## 5 1.0.HCount.Poor4uds Poverty Headcount ($4 a day) The poverty hea…
## 6 1.0.HCount.Vul4to10 Vulnerable ($4-10 a day) Headcount The poverty hea…
## 7 1.0.PGap.1.90usd Poverty Gap ($1.90 a day) The poverty gap…
## 8 1.0.PGap.2.5usd Poverty Gap ($2.50 a day) The poverty gap…
## 9 1.0.PGap.Poor4uds Poverty Gap ($4 a day) The poverty gap…
## 10 1.1.HCount.1.90usd Poverty Headcount ($1.90 a day)-Rural The poverty hea…
## # ℹ 3,957 more rows
pop <- wb_data("SP.POP.TOTL")
write.csv(pop, "population.csv")
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("MSFT", "BAC", "HOOD", "TSLA"), src="yahoo")
## [1] "MSFT" "BAC" "HOOD" "TSLA"
write.zoo(TSLA, "TSLA.csv", sep=",")
##Question 6 and 7
getSymbols("MSFT", src="yahoo",from = "2024-10-01", to = "2025-02-01")
## [1] "MSFT"
##Question 8
which.max(MSFT$MSFT.Open)
## [1] 56
MSFT[which.max(MSFT$MSFT.Open), "MSFT.Open"]
## MSFT.Open
## 2024-12-18 451.32