1 Zakład Bioinformatyki, Instytut Informatyki, Uniwersytet w Białymstoku
✉ Correspondence: Jarosław Kotowicz <j.kotowicz@uwb.edu.pl>
Wybrałem kilka bibiolotek dostępnych w środowisku R
Chwila na obejrzenie
download.file(url = "http://ec.europa.eu/economy_finance/db_indicators/ameco/documents/ameco0.zip",
destfile = "ameco0.zip" )
unzip("ameco0.zip")
Przeanalizujemy jedną z tabel z AMECO.
AMECO1.pl.pop <- AMECO1.pl %>%
slice(2:5) %>%
pivot_longer(
-c(CODE, COUNTRY, `SUB-CHAPTER`, TITLE, UNIT),
names_to = "Year",
values_to = "Population"
) %>%
select(-c(1:3, 5))
AMECO1.pl.pop %>% datatable()
Ilustracja graficzna
AMECO1.pl.pop %>% ggplot(aes(x = Year, y = Population)) +
geom_point(aes(color = TITLE)) +
geom_line(aes(x = Year, y = Population, group = TITLE, color = TITLE), stat="identity") +
scale_x_discrete(breaks = seq(1960, 2022, 5)) +
scale_y_continuous(breaks = seq(0, 40000, 5000), labels = c(0,paste(seq(5, 40, 5), "mln."))) +
labs(title = "Populacja Polski w latach 1960 - 2020",
colour = "Grupy wiekowe",
x = "Rok",
y = "Populacja Polski",
caption = "Opracowanie własne na podstawie danych KE.") +
theme(plot.title = element_text(hjust=0.5))
Podczytanie struktur magazynu danych
Przeszukiwanie magazynu danych w poszukiwaniu danych związanych ze słowem kluczowym
Importowanie konkretnego zbioru danych z magazynu danych Eurosatu
trying URL 'https://ec.europa.eu/eurostat/estat-navtree-portlet-prod/BulkDownloadListing?sort=1&file=data%2Fdemo_r_pjanind2.tsv.gz'
Content type 'application/octet-stream;charset=UTF-8' length 604613 bytes (590 KB)
downloaded 590 KB
Table demo_r_pjanind2 cached at C:\Users\user\AppData\Local\Temp\RtmpsnjNfc/eurostat/demo_r_pjanind2_date_code_TF.rds
# -------->> Get a data frame with information on all available datasets.
oecd_datasets <- get_datasets()
[1] 1366 2
# -------->> Search codes and descriptions of available OECD series
oecd_employment <- search_dataset("employment", oecd_datasets)
# -------->> Get the data structure of a dataset.
oecd_employment_DUR_D <- get_data_structure("DUR_D")
[1] "list"
[1] 12
[1] "VAR_DESC" "COUNTRY" "TIME" "SEX" "AGE" "DURATION"
[7] "FREQUENCY" "OBS_STATUS" "UNIT" "POWERCODE" "REFERENCEPERIOD" "TIME_FORMAT"
Można odnaleźć na stronie OECD metadane zbioru danych.
# -------->> Download OECD data sets
oecd_employment_DUR_D_df <- get_dataset("DUR_D",
filter = list(c("POL"), c("MEN")),
start_time = 2000, end_time = 2018)
oecd_employment_DUR_D_df_f <- oecd_employment_DUR_D_df %>%
filter(DURATION == "UN", AGE != "1524", AGE !="6599", AGE != "900000")
Wykres
oecd_employment_DUR_D_df_f %>%
ggplot(aes(x = obsTime, y = obsValue)) +
geom_point(aes(color = AGE)) +
geom_line(aes(x = obsTime, y = obsValue, group = AGE, color = AGE), stat="identity") +
scale_x_discrete(breaks = seq(2000, 2018, 3)) +
scale_y_continuous(breaks = seq(0, 1250, 250), labels = c(0,paste(seq(250, 1250, 250), "tyś."))) +
labs(title = "Bezrobotni meżczyźni w Polsce wg grup wiekowych",
colour = "Grupy wiekowe",
x = "Rok",
y = "Liczba bezrobotnych",
caption = "Opracowanie własne na podstawie danych OECD.") +
theme(plot.title = element_text(hjust=0.5))
[38;5;238m==[39m [38;5;238mNeed to Learn tidyquant?[39m [38;5;238m====================================================[39m[38;5;32m
Business Science offers a 1-hour course - Learning Lab #9: Performance Analysis & Portfolio Optimization with tidyquant!
[39m[38;5;32m</> Learn more at: https://university.business-science.io/p/learning-labs-pro </>[39m
Użycie
[1] "USD/EUR"
[1] "xts" "zoo"
[1] 179 1
[1] "USD.EUR"
[1] "MSFT"
[1] "xts" "zoo"
[1] 3333 6
[1] "MSFT.Open" "MSFT.High" "MSFT.Low" "MSFT.Close" "MSFT.Volume" "MSFT.Adjusted"
# Bar Chart
MSFT.my %>%
ggplot(aes(x = date, y = close)) +
geom_barchart(aes(open = open, high = high, low = low, close = close)) +
geom_ma(color = "darkgreen") +
coord_x_date(xlim = c("2019-10-01", "2019-12-31"),
ylim = c(130, 165)) +
labs(title = "Wykres słupkowy kursu akcji Microsoft od 01.10 do 31.12 w roku 2019",
x = "Data",
y = "Cena zamknięcia",
caption = "Opracowanie własne na podstawie danych Yahoo Finance.") +
theme(plot.title = element_text(hjust=0.5))
MSFT.my %>%
ggplot(aes(x = date, y = close)) +
geom_candlestick(aes(open = open, high = high, low = low, close = close)) +
geom_ma(color = "darkgreen") +
coord_x_date(xlim = c("2019-10-01", "2019-12-31"),
ylim = c(130, 165)) +
labs(title = "Wykres świecowy kursu akcji Microsoft od 01.10 do 31.12 w roku 2019",
x = "Data",
y = "Cena zamknięcia",
caption = "Opracowanie własne na podstawie danych Yahoo Finance.") +
theme(plot.title = element_text(hjust=0.5))
[1] "nbp_api_response"
$table
[1] "A"
$currency
[1] "euro"
$code
[1] "EUR"
$rates
NA
$table
[1] "A"
$currency
[1] "euro"
$code
[1] "EUR"
$rates
NA
waluta_EUR_A <- get_exchangerate_tables_from_interval(table = "A", from = Sys.Date() - 93, to = Sys.Date())
waluta_EUR_A$content
waluta_EUR_A <- get_exchangerate_from_interval(table = "A", currency_code = "EUR",
from = Sys.Date() - 93, to = Sys.Date())
waluta_EUR_A$content
$table
[1] "A"
$currency
[1] "euro"
$code
[1] "EUR"
$rates
NA