Lorenzo Gaborini's Avatar

Lorenzo Gaborini

@lgaborini.bsky.social

Lausanne based ๐Ÿ‡จ๐Ÿ‡ญ - Senior Data Analyst @IntTestAgency - PhD Forensic Science @unil - MSc Mathematical Engineering @polimi ยฎ๐Ÿ๐Ÿƒโ€โ™€๏ธโ›ท๐Ÿšฒ๐Ÿฅ๐Ÿฝ

17 Followers  |  95 Following  |  33 Posts  |  Joined: 25.12.2023  |  2.0715

Latest posts by lgaborini.bsky.social on Bluesky

Without leaving the tidyverse, just extract the numbers with readr::parse_number(), then use order() on the string:

Treatment <- c("Control", "Asprin 10mg/day", "Asprin 50mg/day", "Asprin 100mg/day", "Acetomycin 100mg/day" "Acetomycin 1000mg/day")

Treatment[order(readr::parse_number(Treatment))]

02.10.2025 08:37 โ€” ๐Ÿ‘ 2    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

ggplot2 and now plumber2! What a year! ๐Ÿ™Œ

24.09.2025 12:53 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

It is like saying that I know how to fix a faucet because I can call a plumber

22.09.2025 07:51 โ€” ๐Ÿ‘ 2    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Another instance of the Norway problem!

22.09.2025 07:23 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

Most companies donโ€™t need deep learning. They need clean joins, honest metrics, and interpretable results.
Startups often chase GPU clusters before fixing their CSVs.

#DataScience #MachineLearning #AI #RStats

17.09.2025 22:17 โ€” ๐Ÿ‘ 14    ๐Ÿ” 6    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Preview
How thousands of โ€˜overworked, underpaidโ€™ humans train Googleโ€™s AI to seem smart Contracted AI raters describe grueling deadlines, poor pay and opacity around work to make chatbots intelligent

How thousands of โ€˜overworked, underpaidโ€™ humans train Googleโ€™s AI to seem smart

www.theguardian.com/technology/2...

15.09.2025 06:11 โ€” ๐Ÿ‘ 6    ๐Ÿ” 2    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

TIL! I've always used {tibble} enframe()/deframe()

08.09.2025 08:16 โ€” ๐Ÿ‘ 3    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Microsoft Powertoys: calculator, fuzzy file search, OCR text extractor, advanced paste and SO MUCH MORE with a single keystroke from anywhere! ๐Ÿ‘Œ

05.09.2025 07:00 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

And then it's up to you to reflow anything since it's too difficult for them to open a text file. Not to mention when they require Track Changes.

27.08.2025 07:30 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Pairs up nicely with the Norway problem!

26.08.2025 16:19 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

In princilple you can play around with the `cue` to avoid some of the invalidation causes. But I'm guilty too, I like to dump intermediate/cleaned results to csv and rds, even if I completely trust my pipeline. "You never know".

26.08.2025 07:28 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

One solution: fix the function environment of \() by making one on the spot. Modify the loop contents with:

list_vec[[i]] <- local({
i <- i
\() paste("vec is:", i)
})

Or manually::

e <- new.env()
e$i <- i
environment(list_vec[[i]]) <- e
list_vec[[i]] <- \() paste("vec is:", i)

22.08.2025 09:32 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Proof:

rlang::fn_env(list_vec[[1]]) # <environment: R_GlobalEnv>
rlang::fn_env(list_vec[[2]]) # <environment: R_GlobalEnv>

list_vec[[1]]() # "bar"
list_vec[[2]]() # "bar"

i <- "other"
list_vec[[1]]() # "other"

22.08.2025 07:26 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

The functional wants to access the name `i` when it is called later, so it looks up in the function environment. Since each iteration is executed inside R_GlobalEnv, the value of `i` is not fixed.

22.08.2025 07:25 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

No it's because of the function environment of the \() functional (R_GlobalEnv), which is associated during its creation (each iteration of the loop).

22.08.2025 07:25 โ€” ๐Ÿ‘ 2    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

More than 10 years of R, and this still caught me off guard... #rstats

vec <- c("foo", "bar")
list_vec <- list()

for (i in vec) {
list_vec[[i]] <- \() paste("vec is:", i)
}

list_vec[[1]]() # "vec is: bar"
list_vec[[2]]() # "vec is: bar"

21.08.2025 22:25 โ€” ๐Ÿ‘ 7    ๐Ÿ” 1    ๐Ÿ’ฌ 3    ๐Ÿ“Œ 0

For VSCode I liked vscode-data-preview when it worked!

30.07.2025 23:05 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Amazing! I always end up doing something that could benefit from this (a big qmd with wrangling and literate exploration โ€” for me โ€” and a qmd with the selected results)

27.07.2025 14:28 โ€” ๐Ÿ‘ 2    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Pasta is lunch/dinner soup

23.07.2025 15:06 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

And some are still against NSE!

23.07.2025 08:25 โ€” ๐Ÿ‘ 1    ๐Ÿ” 1    ๐Ÿ’ฌ 2    ๐Ÿ“Œ 0

VSCode is a much more pleasant coding experience (better multi-cursors, multi-file regex search, minimap, goto anything), and the current Copilot works pretty well for oneliners! I just miss R-specific workflows (debugging, Rmd/Qmd auto-loaded params, tests) but they're slowly coming

22.07.2025 20:19 โ€” ๐Ÿ‘ 2    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Why the slots and the quoted variables?

06.07.2025 21:16 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

Why not go full {lubridate}?
parse_date_time("May-23", "bd")

28.05.2025 07:15 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

Blink twice for help

20.05.2025 17:12 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

It's much easier if you can start from the rocker images! They already have the whole tidyverse preinstalled (until you need a specific version: renv+PPM+pak helps a lot but it's still lots of dependencies)

23.04.2025 09:17 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

I discovered that too by reading {readr}'s code!

19.04.2025 07:38 โ€” ๐Ÿ‘ 2    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

They are also never completely true or false โ€” they work well inside their own (i.e. the observer's) limits. Geocentrism is "true" if you do not care about astronomy!

13.04.2025 21:51 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

I hope no one is working on {err} (a spell-checker?) ๐Ÿคฃ

26.02.2025 07:31 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Why use air.toml instead of the .editorconfig?

23.02.2025 09:37 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

I routinely copy things from dplyr: there are pages for specific concepts (non-functions) with inline references across the whole package. Super useful to document bigger packages (with data dictionaries, etc.)! Also, reactable and gt for the huge list of examples!

05.02.2025 15:19 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

@lgaborini is following 20 prominent accounts