I hereby claim:
- I am nacnudus on github.
- I am nacnudus (https://keybase.io/nacnudus) on keybase.
- I have a public key ASCRo_YM6aOXHQOlSQTyw8plq2ubGwakYHS_kdQ07xiQ9wo
To claim this, I am signing this object:
| timeHMS_formatter <- function(x) { | |
| x[is.na(x)] <- 0 | |
| h <- trunc(x * 24) | |
| m <- trunc(x * 24 * 60) | |
| s <- x * 24 * 60 * 60 %% 60 | |
| s <- round(s, 2) | |
| lab <- sprintf('%02d:%02d:%02d', h, m, s) # Format the strings as HH:MM:SS | |
| lab <- gsub('^00:', '', lab) # Remove leading 00: if present | |
| lab <- gsub('^0', '', lab) # Remove leading 0 if present | |
| } |
| ``` r | |
| library(xml2) | |
| library(dplyr) | |
| library(purrr) | |
| library(stringr) | |
| # From the root node: | |
| # If has_children, then recurse. | |
| # Otherwise, attributes, value and children (nested) to data frame. |
| library(tidyxl) | |
| library(tidyverse) | |
| library(unpivotr) | |
| library(rvest) | |
| library(stringr) | |
| library(ggrepel) | |
| download.file("https://smartstart.services.govt.nz/assets/files/Top-baby-names-1954-2016.xlsx", | |
| destfile = "babynames.xlsx", mode = "wb") | |
| babies <- tidy_xlsx("babynames.xlsx") |
| library(data.table) | |
| ?`[.data.table` | |
| DT <- data.table(x=rep(c("b","a","c"),each=3), y=c(1,3,6), v=1:9) | |
| X <- data.table(x=c("c","b"), v=8:7, foo=c(4,2)) | |
| colnames(DT) | |
| # [1] "x" "y" "v" |
| # Rcpp NAs vs std::vector | |
| library(Rcpp) | |
| cppFunction(" | |
| List test1() { | |
| return List::create( | |
| NumericVector::create(NA_REAL), | |
| IntegerVector::create(NA_INTEGER), | |
| LogicalVector::create(NA_LOGICAL), | |
| CharacterVector::create(NA_STRING)); |
| # Load all registers into various databases | |
| library(tidyverse) | |
| library(DBI) | |
| library(registr) # https://github.com/nacnudus/registr | |
| library(stringr) | |
| library(getPass) | |
| library(here) | |
| beta <- rr_registers() |
| #' Match the Civil Service People Survey to the government-organisation register | |
| library(tidyverse) | |
| library(RegistersClientR) | |
| #' Download the survey and the register | |
| survey_path <- "https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/659571/Civil_Service_People_Survey_2017_All_Organisation_Scores__CSV_.csv" | |
| survey <- read_csv(survey_path)[, 1:5] | |
| govorg <- |
| # Import the participation data | |
| library(tidyverse) | |
| library(tidyxl) # You'll need the dev versions devtools::install_github("nacnudus/tidyxl") | |
| library(unpivotr) # You'll need the dev versions devtools::install_github("nacnudus/unpivotr") | |
| library(here) | |
| path <- here("inst", "extdata", "australian_marriage_law_postal_survey_2017_-_participation_final.xlsx") | |
| book <- xlsx_cells(path) | |
| formats <- xlsx_formats(path) |
| # To install dependencies | |
| # install.packages(c("devtools", "tidyverse")) | |
| # install_github("openregister/RegistersClientR") | |
| library(tidyverse) | |
| library(RegistersClientR) | |
| register <- rr_register("register") | |
| register %>% |
I hereby claim:
To claim this, I am signing this object: