zx8754's Avatar

zx8754

@zx8754.bsky.social

Analysis - Data - Analysis - Data - Volleyball - Father - #rstats #STEM #ProstateCancer

118 Followers  |  948 Following  |  139 Posts  |  Joined: 11.11.2023  |  2.2087

Latest posts by zx8754.bsky.social on Bluesky

Stack Overflow has slowed down since AI, but every so often I still come across a brilliant gem of an answer you can learn a lot from.

04.11.2025 07:34 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
listogram plot - Histogram of three-letter words, with the words themselves shown on the plot.

listogram plot - Histogram of three-letter words, with the words themselves shown on the plot.

#rstats plot of the day - "Listogram" by r2evans

stackoverflow.com/a/79808261/6...

04.11.2025 07:34 β€” πŸ‘ 3    πŸ” 1    πŸ’¬ 1    πŸ“Œ 0
quote from the linked post: "my default assumption is nothing is going to work"

https://blog.genesmindsmachines.com/p/we-still-cant-predict-much-of-anything

quote from the linked post: "my default assumption is nothing is going to work" https://blog.genesmindsmachines.com/p/we-still-cant-predict-much-of-anything

"my default assumption is nothing is going to work" - @clauswilke.com

23.10.2025 14:04 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

"if" only handles scalars, "ifelse" handles vectors. If condition is longer than 1, comparing them doesn't make sense, right?

23.10.2025 10:50 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

as.integer(condition)

23.10.2025 10:30 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

set.seed((\(x) sum(x %% 10) + length(x))(as.integer(charToRaw("Forty-two"))))

#rstats

23.10.2025 08:33 β€” πŸ‘ 3    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Post image

Men with BRCA1 and BRCA2 mutations should get annual #ProstateCancer screening.

The IMPACT trial finds BRCA1 carriers are 3 times more likely to have aggressive prostate cancers than non-carriers.

Results from the international trial shared at @myesmo.bsky.social

www.icr.ac.uk/about-us/icr...

17.10.2025 08:05 β€” πŸ‘ 3    πŸ” 3    πŸ’¬ 0    πŸ“Œ 1

#rstats easier to compare the ratios

08.10.2025 10:15 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Post image

It had been gradually declining by about 5 million before the war, then dropped by another 5 million between 2022 and 2025.

08.10.2025 09:22 β€” πŸ‘ 2    πŸ” 1    πŸ’¬ 0    πŸ“Œ 0
Preview
Tuzla Municipality: Stop at the Crosswalk, Stop the Accidents β€’ Ads of the Worldβ„’ | Part of The Clio Network What if a pedestrian crossing could tell the story of every accident that happened on it? In Tuzla, Istanbul, the stripes of a crosswalk were transformed into a living accident chart. Each line visua...

Looks like it is real - www.adsoftheworld.com/campaigns/st...

I understand the awareness function, but I'd rather see humped crossings or traffic calming measures before the crossings. The issue isn't visibility, it's the driving culture of ignoring them that needs to change.

01.10.2025 11:10 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

one day I will never master these

08.09.2025 06:50 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
"Hence, in the R Core meetings in Toulouse in 2019, it was decided to move towards using stringsAsFactors = FALSE by default, ideally starting with the 4.0.0 release."

"Hence, in the R Core meetings in Toulouse in 2019, it was decided to move towards using stringsAsFactors = FALSE by default, ideally starting with the 4.0.0 release."

Blame these guys πŸ€ͺ

blog.r-project.org/2020/02/16/s...

05.09.2025 07:58 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Screenshot of the answer at: https://unix.stackexchange.com/a/153662/16560

Screenshot of the answer at: https://unix.stackexchange.com/a/153662/16560

Ah, thought it was a hidden joke from devs, but it isn't

unix.stackexchange.com/a/153662/16560

05.09.2025 07:50 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 0    πŸ“Œ 1
Post image

I use Google as calculator, too. But recently discovered that the iPhone Notes app does the same:

04.09.2025 20:08 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Create a data.table row-wise
Aliases: rowwiseDT

Keywords:

### ** Examples

rowwiseDT(
  A=,B=, C=,
  1, "a",2:3,
  2, "b",list(5)
)
       A      B      C
   <num> <char> <list>
1:     1      a    2,3
2:     2      b      5

Create a data.table row-wise Aliases: rowwiseDT Keywords: ### ** Examples rowwiseDT( A=,B=, C=, 1, "a",2:3, 2, "b",list(5) ) A B C <num> <char> <list> 1: 1 a 2,3 2: 2 b 5

You can define a tibble row-by-row with tribble():

tribble(
  ~x, ~y,  ~z,
  "a", 2,  3.6,
  "b", 1,  8.5
)
#> # A tibble: 2 Γ— 3
#>   x         y     z
#>   <chr> <dbl> <dbl>
#> 1 a         2   3.6
#> 2 b         1   8.5

You can define a tibble row-by-row with tribble(): tribble( ~x, ~y, ~z, "a", 2, 3.6, "b", 1, 8.5 ) #> # A tibble: 2 Γ— 3 #> x y z #> <chr> <dbl> <dbl> #> 1 a 2 3.6 #> 2 b 1 8.5

#rstats #TIL I knew about tibble::tribble, but just discovered data.table::rowwiseDT.

"creates a data.table object by specifying a row-by-row layout. This is convenient and highly readable for small tables."

02.09.2025 06:49 β€” πŸ‘ 4    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Preview
ggfun: Miscellaneous Functions for 'ggplot2' Useful functions and utilities for 'ggplot' object (e.g., geometric layers, themes, and utilities to edit the object).

It’s from ggfun: cran.r-project.org/package=ggfun

02.09.2025 04:06 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Preview
ggfun: Miscellaneous Functions for 'ggplot2' Useful functions and utilities for 'ggplot' object (e.g., geometric layers, themes, and utilities to edit the object).

Looks like it is from ggfun package. Thanks for looking into this.

cran.r-project.org/package=ggfun

01.09.2025 13:44 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Post image

update: Searching GitHub R repos gives 1.5K hits. Looking at couple of pages, it looks like it is from ggfun - cran.r-project.org/web/packages...

01.09.2025 13:30 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

Yes, checked the magrittr, too, nothing.

01.09.2025 13:27 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

I'm afraid there’s no context, it comes from another user in a private group chat. I've asked for clarification and will provide an update once they respond with more info.

01.09.2025 09:22 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

#rstats pipe help, where is this from? I am guessing it is "modify and re-assign".

%<+%

Google didn't help, Gemini says it is invalid R code or it is a regex. ChatGPT says it is from ggplot, searching GitHub didn't help. But found this function ggplot2::`%+replace%`(), are they related?

01.09.2025 07:48 β€” πŸ‘ 4    πŸ” 0    πŸ’¬ 3    πŸ“Œ 0

They like to keep us floored.

18.08.2025 12:15 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

ggpairs for first 4 PCs would be interesting to see.

24.07.2025 09:12 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 2    πŸ“Œ 0
# for loop
f <- function(x, y){
  out <- vector("integer", length(x))
  yy <- y
  for(i in seq_along(x)) {
    mm <- match(x[ i ], yy)
    out[ i ] <- mm
    yy[ mm ] <- NA
  }
  out
}
# recursive version
fr <- function(x, y, out = integer(length(x)), i = 1) {
  if (i > length(x)) return(out)
  
  mm <- match(x[ i ], y)
  out[ i ] <- mm
  if (!is.na(mm)) y[ mm ] <- NA
  
  fr(x, y, out, i + 1)
}

f(c("a", "b", "a"), c("a", "b", "c", "a"))
# [1] 1 2 4
fr(c("a", "b", "a"), c("a", "b", "c", "a"))
# [1] 1 2 4

# for loop f <- function(x, y){ out <- vector("integer", length(x)) yy <- y for(i in seq_along(x)) { mm <- match(x[ i ], yy) out[ i ] <- mm yy[ mm ] <- NA } out } # recursive version fr <- function(x, y, out = integer(length(x)), i = 1) { if (i > length(x)) return(out) mm <- match(x[ i ], y) out[ i ] <- mm if (!is.na(mm)) y[ mm ] <- NA fr(x, y, out, i + 1) } f(c("a", "b", "a"), c("a", "b", "c", "a")) # [1] 1 2 4 fr(c("a", "b", "a"), c("a", "b", "c", "a")) # [1] 1 2 4

24.07.2025 09:00 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

Smells like recursive.

24.07.2025 08:18 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

Challenge: check if you wish but do no reply to any work emails.

24.07.2025 07:40 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
paletteer_c("grDevices::Earth", 30)

https://r-charts.com/color-palettes/

paletteer_c("grDevices::Earth", 30) https://r-charts.com/color-palettes/

I think they are called Earthy colours

24.07.2025 07:34 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Image source: https://blogs.sas.com/content/sastraining/2019/01/24/re-creating-a-hans-rosling-graph-animation-with-sas/

Hans Rosling bubble chart presentation TED Talks:
The best stats you've ever seen | Hans Rosling
https://www.youtube.com/watch?v=hVimVzgtD6w

Image source: https://blogs.sas.com/content/sastraining/2019/01/24/re-creating-a-hans-rosling-graph-animation-with-sas/ Hans Rosling bubble chart presentation TED Talks: The best stats you've ever seen | Hans Rosling https://www.youtube.com/watch?v=hVimVzgtD6w

22.07.2025 08:50 β€” πŸ‘ 10    πŸ” 2    πŸ’¬ 0    πŸ“Œ 0
library(dplyr)

df1 |>
  mutate(mycol1 = "too") |>
  mutate(mycol2 = "much") |>
  mutate(mycol3 = "typing")

df1 |>
  mutate(mycol1 = "this",
         mycol2 = "is",
         mycol3 = "less")

library(dplyr) df1 |> mutate(mycol1 = "too") |> mutate(mycol2 = "much") |> mutate(mycol3 = "typing") df1 |> mutate(mycol1 = "this", mycol2 = "is", mycol3 = "less")

Similarly, long long time ago, I realised mutate can be called just once πŸ€¦β€β™‚οΈ

21.07.2025 07:43 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

As base::rbind also takes more than two dataframes as input, I expected at least the same from dplyr::bind_rows. And bind_rows handles rownames, factor levels, and mismatched column names better. #rstats

21.07.2025 07:37 β€” πŸ‘ 3    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

@zx8754 is following 19 prominent accounts