Skip to content

Instantly share code, notes, and snippets.

View njtierney's full-sized avatar
🐝
Back at work

Nicholas Tierney njtierney

🐝
Back at work
View GitHub Profile
library(palmerpenguins)

penguins[1:5, c(3)] <- -99
penguins[1:5, c(4)] <- -98

penguins
#> # A tibble: 344 × 8
#>    species island    bill_length_mm bill_depth_mm flipper_…¹ body_…² sex    year
#>    <fct>   <fct>              <dbl>         <dbl>      <int>   <int> <fct> <int>
covid_url <- "https://covidlive.com.au/report/daily-vaccinations/aus"

library(polite)
library(tidyverse)
library(rvest)
#> 
#> Attaching package: 'rvest'
#> The following object is masked from 'package:readr':
#> 
library(tidyverse)
library(rvest)
#> 
#> Attaching package: 'rvest'
#> The following object is masked from 'package:readr':
#> 
#>     guess_encoding
library(polite)
###
# currently a lot of the helper functions in greta need to be rewritten as they
# use various TF1 things that break a lot of existing code
# and as far as I can tell, there are issues with how some of the code
# is initialising TF with dag$define_tf()
# - so this is happening and then the free state doesn't
# exist...and I'm not sure how to resolve this
# current tests that fail:
# (2 errors) test_calculate (with random seed issues)
# (34 errors) test_distributions
library(tidyverse)
library(naniar)

dat <- tibble(
  x = c(".", 123, 321, "."),
  y = rnorm(4),
  z = c(43, 42, ".", "."),
  misc = c("full.name", "last.name", "frank", "ocean"),
  misc2 = c("full.", ".name", "frank", "ocean")
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#&gt; intersect, setdiff, setequal, union
library(naniar)
library(tidyverse)

riskfactors
#> # A tibble: 245 × 34
#>    state sex      age weight_lbs height_…¹   bmi marital pregn…² child…³ educa…⁴
#>    <fct> <fct>  <int>      <int>     <int> <dbl> <fct>   <fct>     <int> <fct>  
#>  1 26    Female    49        190        64  32.7 Married <NA>          0 6      
#>  2 40    Female    48        170        68  25.9 Divorc… <NA>          0 5      
library(tidyverse)
library(clock)

dat_cov <- expand_grid(
    year = 2021,
    month = 1:3,
    id = LETTERS[1:3]
  ) |>
  mutate(
library(mgcv)
#> Loading required package: nlme
#> This is mgcv 1.8-40. For overview type 'help("mgcv-package")'.
library(tidyverse)
library(ggplot2)
set.seed(2022-08-08)

# the fake function we would like to mirror
f <- function(age) {
library(mgcv)
#> Loading required package: nlme
#> This is mgcv 1.8-40. For overview type 'help("mgcv-package")'.
library(tidyverse)
library(ggplot2)
set.seed(2022-08-08)
# the fake function we would like to mirror
f <- function(age) {