This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "goToFileFunction": "Ctrl+P", | |
| "insertPipeOperator": "Ctrl+Shift+M", | |
| "restartR": "Ctrl+R", | |
| "activateTerminal": "Ctrl+3", | |
| "browseAddins": "", | |
| "closeProject": "", | |
| "closeTerminal": "", | |
| "sendTerminalToEditor": "", | |
| "newTerminal": "Ctrl+T", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Recursive `glue::glue` based on | |
| # https://github.com/SuperMayo/gonfig/blob/master/R/glue.R | |
| # but simplified | |
| rglue <- function(string, ...) { | |
| glued <- glue::glue(string, ...) | |
| if (glued==string) glued else rglue(glued, ...) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Usage example (disclaimer: fictitious email addresses, any resemblance to real ones is coincidental): | |
| ## emailAddressToInstitutionName(c('[email protected]', | |
| ## '[email protected]')) | |
| ##> "Ministère du Travail, du Plein emploi et de l'Insertion" | |
| ##> "Ministerie van Sociale Zaken en Werkgelegenheid | Rijksoverheid.nl" | |
| # Required packages: `magrittr`, `rvest` | |
| library(magrittr) # for the %>% operator | |
| emailAddressToInstitutionName <- function(charvec_of_email_addresses, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # `mschart` and `officer` R packages are required | |
| # `magrittr` required for the %>% pipe | |
| scatter_plot <- | |
| mschart::ms_scatterchart( | |
| data=iris, x="Sepal.Length", | |
| y="Sepal.Width", group="Species" | |
| ) %>% | |
| mschart::chart_settings(scatterstyle="marker") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| main = do | |
| putStrLn $ show $ add (MyInt 1) (MyInt 3) | |
| -- MyInt 4 | |
| putStrLn $ show $ add (MyInt 13) (MyString "B") | |
| -- MyString "13B" | |
| putStrLn $ show $ add (MyString "B") (MyInt 13) | |
| -- MyString "B13" | |
| putStrLn $ show $ add (MyString "a") (MyString "b") | |
| -- MyString "ab" | |
| putStrLn $ show $ add' $ IntInt 1 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| options(width=200) | |
| if (interactive()) { | |
| message('================================================================================') | |
| ab <- function(sym_as_str, fun) | |
| makeActiveBinding(sym_as_str, fun, .GlobalEnv) | |
| library(magrittr) | |
| message('- Imported package `magrittr`') | |
| library(data.table) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(magrittr) | |
| library(data.table) | |
| download.file('https://ec.europa.eu/economy_finance/db_indicators/ameco/documents/ameco0.zip', | |
| 'ameco0.zip') | |
| time_stamp <- | |
| 'https://ec.europa.eu/info/business-economy-euro/indicators-statistics/economic-databases/macro-economic-database-ameco/download-annual-data-set-macro-economic-database-ameco_en' %>% | |
| rvest::read_html() %>% | |
| rvest::html_elements(xpath='//*[@id="block-ewcms-theme-main-page-content"]/article/div/div/div/div[2]/div/div/p[1]/text()[2]') %>% | |
| rvest::html_text() %>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(magrittr) | |
| monthToQuarter <- function(charvec, safe=TRUE) { | |
| # monthToQuarter(c('2022M01','2022M02','2022M03','2022M04', | |
| # NA_character_,'2022M12')) | |
| # # "2022Q1" "2022Q1" "2022Q1" "2022Q2" NA "2022Q4" | |
| if (safe) | |
| stopifnot(all(grepl('^[1-2][0-9]{3}M[0-1][0-9]', | |
| charvec) | is.na(charvec))) | |
| yr <- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ## Example: ⮦ time=3 missing | |
| # library(magrittr) | |
| # data.table(time = c(1,2, 4,5,6, | |
| # 1,2), | |
| # my_x = c(11:15, | |
| # 11,12), | |
| # my_y = c(101,103,105,NA,109, | |
| # 111,121), | |
| # group = c(rep.int('a',5), | |
| # rep.int('b',2))) %>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import eurostat | |
| import pandas as pd | |
| def importData(EurostatDatasetCode, flags=False): | |
| """ | |
| Import a dataset from Eurostat as a flat/melted table (pandas dataframe) | |
| Parameter | |
| ---------- | |
| EurostatDatasetCode : str |