Skip to content

Commit 7b2ff6a

Browse files
authored
docs: 📝 update filter example in guide (#274)
# Description ~~`foed_dato` is now a `date` in the simulated data, so the mutate to `strptime()` started failing locally.~~ Edit: Regenerating `koen` and using that in the filter example, so we have full control of the type regardless of potential future changes upstream. Needs a quick review. ## Checklist - [X] Ran `just run-all`
1 parent 55e6bd5 commit 7b2ff6a

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

vignettes/fastreg.qmd

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ bef_list <- simulate_register(
5555
"bef",
5656
c("", "1999", "1999_1", "2020"),
5757
n = 1000
58-
)
58+
) |>
59+
# Randomly (re)generate koen, so we don't rely on any potential future
60+
# changes to the simulated data from osdc.
61+
purrr::map(\(x) {
62+
x |> dplyr::mutate("koen" = sample(c(1, 2), 1000, replace = TRUE))
63+
})
5964
6065
lmdb_list <- simulate_register(
6166
"lmdb",
@@ -218,14 +223,11 @@ file
218223
```
219224

220225
The resulting DuckDB table can be filtered and transformed with `dplyr`.
221-
For example, `foed_dato` is stored as a character in the simulated data
222-
(`"YYYYMMDD"`), so you can change it to a date (using `strptime()`) and
223-
then filter:
226+
For example, you can filter the data:
224227

225228
```{r filter-file}
226229
file |>
227-
dplyr::mutate(foed_dato = strptime(foed_dato, "%Y%m%d")) |>
228-
dplyr::filter(koen == 2 & foed_dato > "2000-01-01") |>
230+
dplyr::filter(koen == 2) |>
229231
dplyr::compute()
230232
```
231233

0 commit comments

Comments
 (0)