/
index.qmd
148 lines (127 loc) · 3.91 KB
/
index.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
title: Paul Johnson
pagetitle: Paul Johnson
subtitle: Using Causal Inference & Machine Learning to Confirm My Priors
image: assets/img/paul/paul.webp
image-alt: Me looking handsome as hell
description-meta: |
I am a data scientist interested in using my knowledge of causal inference,
statistics, probabilistic thinking, and machine learning to understand human
behaviour.
twitter-card:
title: Paul Johnson
description: |
A Data Scientist Using Causal Inference & Machine Learning to Confirm His Priors.
image: assets/img/paul/paul.webp
about:
template: solana
image-width: 28em
id: hero-heading
links:
- icon: mastodon
aria-label: Mastodon
href: https://fosstodon.org/@paulj1989
- icon: linkedin
aria-label: LinkedIn
href: https://linkedin.com/in/paulj1989
- icon: github
aria-label: GitHub
href: https://github.com/paulj1989
- text: "{{< iconify fa6-brands kaggle >}}"
aria-label: Kaggle
href: https://kaggle.com/paulrjohnson
- text: "{{< iconify fa6-brands google-scholar >}}"
aria-label: Google Scholar
href: https://scholar.google.com/citations?user=Op4yo3YAAAAJ&hl=en
- icon: cup-hot-fill
aria-label: Buy Me a Coffee
href: https://www.buymeacoffee.com/paulj1989
page-layout: full
css: assets/css/index.css
include-in-header: assets/umami.html
echo: false
---
<br><br><br><br>
::: {#hero-heading}
I am a data scientist at NHS South, Central and West CSU. I am interested in applying my knowledge of causal inference, statistics, probabilistic thinking, and machine learning to problems of understanding human behaviour.
At heart, I want to understand how the world works, and I enjoy telling stories that help others do the same, leveraging data and my quantitative skill set in the process.
:::
```{r}
#| label: manual-redirects
# import redirects
manual_redirects <- readr::read_lines(here::here("assets", "_manualredirects"))
```
```{r}
#| label: blog-redirects
# get file paths for all blog posts
get_file_paths <-
function(folder) {
blog_posts <-
list.dirs(
path = c(here::here(folder)),
full.names = FALSE,
recursive = FALSE
) |>
tibble::as_tibble_col(column_name = "path") |>
dplyr::mutate(folder = folder)
}
# create & extract shortened redirects
blog_posts <-
# get blog post file paths
purrr::map("blog", get_file_paths) |>
# row-bind file paths
purrr::list_rbind() |>
dplyr::mutate(
# remove date slug
blog_title = stringr::str_remove(path, "(?!\\-)\\d{4}-\\d{2}-\\d{2}-"),
# create short path
short_path = paste0(folder, "/", blog_title),
# combine old path and new path to create redirect rule
redirects = paste0("/", short_path, " ", "/", folder, "/", path)
)
blog_redirects <-
blog_posts |>
dplyr::pull(redirects)
```
```{r}
#| label: category-redirects
# get categories from blog posts
get_categories <-
function(post) {
file <- here::here("blog", post) |> fs::path("index.qmd")
if (!fs::file_exists(file)) {
return(character(0))
}
file |>
readr::read_lines() |>
stringr::str_subset("^categories:") |>
stringr::str_extract("\\[.*\\]") |>
stringr::str_remove_all("[\\[\\]]") |>
stringr::str_split(", ") |>
purrr::list_c()
}
# extract categories
categories <-
# blog post categories
purrr::map(blog_posts |> dplyr::pull(path), get_categories) |>
# concatenate categories into a vector
purrr::list_c() |>
unique() |>
stringr::str_replace_all(" ", "%20")
# extract tags
tags <-
categories |>
stringr::str_to_lower() |>
stringr::str_replace_all("%20", "-")
# write category redirects
category_redirects <-
paste0("/tags/", tags, " ", "/blog/#category=", categories)
```
```{r}
#| label: write-redirects
# write the _redirects file
readr::write_lines(
x = c(manual_redirects, blog_redirects, category_redirects),
file = here::here("_redirects")
)
```