Steven P. Sanderson II, MPH

New Book: packt.link/oTyZJ | R - install.packages("healthyverse") | #SQL | opinions are mine | #rstats | Mainly though my wife and kids :) | Advisor to DoTadda - All posts delete in 12 months.

Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-28
Today's post in on #Python #ControlFlow.

I'm learning as I go so be kind :)

Post: https://www.spsanderson.com/steveondata/posts/2025-05-28/

#Python #Blog #FlowControl #ifelse #code
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-26

Want to generate random numbers from a distribution? Todays article has you covered: spsanderson.com/steveondata/po

#R #RStats #Blog

Want to generate random numbers from a distribution? Todays article has you covered: https://www.spsanderson.com/steveondata/posts/2025-05-26/

#R #RStats #Blog
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-23

If you are looking to use the cubist algo for regression and want to get it into shape then use the healthyR.ai package and the hai_cubist_data_prepper() function.

Link: spsanderson.com/healthyR.ai/re

#regression #tidymodels #data #algorithm #cubist

If you are looking to use the cubist algo for regression and want to get it into shape then use the healthyR.ai package and the hai_cubist_data_prepper() function.

Link: https://www.spsanderson.com/healthyR.ai/reference/hai_cubist_data_prepper.html

#regression #tidymodels #data #algorithm #cubist
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-23

Finally got on the #Python bandwagon, sort of. Today I started my series on python programming. I'm learning as I go.

Link: spsanderson.com/steveondata/po

#Programming #Code #Python #Blog #Beginner #Basics

Finally got on the #Python bandwagon, sort of. Today I started my series on python programming. I'm learning as I go.

Link: https://www.spsanderson.com/steveondata/posts/2025-05-23/

#Programming #Code #Python #Blog #Beginner #Basics
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-19
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-16

Today's article went back to #Linux I tried my best to write about #Arrays and to provide some simple practical examples.

If you want to read more then just follow this link -> spsanderson.com/steveondata/po

Today's Title: Arrays in Linux: A Complete Guide for Beginners

Happy Coding πŸš€

#Blog #Technology #Coding #Programming #CLI

Today's article went back to #Linux I tried my best to write about #Arrays and to provide some simple practical examples.

If you want to read more then just follow this link -> https://www.spsanderson.com/steveondata/posts/2025-05-16/

Today's Title: Arrays in Linux: A Complete Guide for Beginners

Happy Coding πŸš€ 

#Blog #Technology #Coding #Programming #CLI
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-15

Same as yesterday, but this time, making a 2D Discrete Random Walk with my #R #Package #RandomWalker

#R #RStats #RProgramming #RandomWalks #Visual #ggplot2

A scatterplot titled "2D Random Walk Non-Outliers Only." It displays multiple colored linear paths representing random walks in a 2D space, constrained to non-outlier data points. The x-axis is labeled "Cumulative Sum X," and the y-axis is labeled "Cumulative Sum Y." The paths are laid out in a grid-like pattern with varied colors.A scatterplot titled "2D Random Walks with Outliers Highlighted." It shows multiple colored random walk paths in a 2D space, with outliers prominently highlighted in bold red dashed lines. Non-outliers are displayed in lighter colors. Black dashed horizontal and vertical lines indicate threshold boundaries for outlier detection. The x-axis is labeled "Cumulative Sum X," and the y-axis is labeled "Cumulative Sum Y."A scatterplot titled "2D Random Walk Outliers Only." It showcases only the outlier random walk paths in a 2D space, displayed in various colors on a white background. Black dashed horizontal and vertical lines mark the threshold boundaries for outlier detection. The x-axis is labeled "Cumulative Sum X," and the y-axis is labeled "Cumulative Sum Y."A screenshot of R programming code written for generating 2D random walks, analyzing outliers, and plotting results. The code uses libraries such as RandomWalker, dplyr, ggplot2, and tidyr. It calculates confidence intervals, identifies outliers, and generates three types of plots: non-outliers, outliers, and highlighted outliers. The syntax is color-coded, with comments explaining each step.
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-14

As i write theese it’s bringing ideas to my head to maybe make some new functions

Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-14

Generate and visualize a Two Dimensional Random Walk in #R with #RandomWalker

#R #RStats #RProgramming #Code

A 2D scatter plot titled "2D Random Walks with Outliers Highlighted," combining both non-outlier and outlier trajectories. Non-outlier walks are displayed in various colors, while outliers are highlighted in bold red dashed lines. Black dashed lines denote confidence interval boundaries, and the x-axis and y-axis are labeled "Cumulative Sum X" and "Cumulative Sum Y," respectively.A 2D scatter plot titled "2D Random Walk Outliers Only," depicting random walk trajectories in various colors. The x-axis is labeled "Cumulative Sum X," and the y-axis is labeled "Cumulative Sum Y." Black dashed lines mark boundary limits, highlighting walks identified as outliers that extend beyond the main cluster.A 2D scatter plot titled "2D Random Walk Non-Outliers Only," showing multiple random walk trajectories in various colors. The x-axis is labeled "Cumulative Sum X," and the y-axis is labeled "Cumulative Sum Y." The trajectories are concentrated around the origin and do not include any outliers.A screenshot of an R script for generating and visualizing 2D random walks. The code uses the RandomWalker, dplyr, and ggplot2 libraries to compute random walks, identify outliers, and plot results. Key sections include calculating confidence intervals, filtering outliers, and creating customized plots with distinct visual styling for outliers and non-outliers.
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-14

πŸ” Need to create a vector of zeros in R? Well, today I wrote about how to use numeric(), integer(), and rep() to initialize vectors efficiently.

These are great tools for pre-allocating memory.

Read more at spsanderson.com/steveondata/po

#R #rstats #data #code #stats #Blog #Programming #Data

πŸ” Need to create a vector of zeros in R? Check out this quick guide! Today I wrote about how to use numeric(), integer(), and rep() to initialize vectors efficiently. 

These are great tools for pre-allocating memory.

Read more at https://www.spsanderson.com/steveondata/posts/2025-05-14/

#R #rstats #data #code #stats #Blog #Programming #Data
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-13

#opinion President Trump is taking a $400 million bribe.

Prove me wrong.

#emoluments #DJT #Trump #DumpTrump

Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-12

The resulting Image.

The resulting Image.
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-12

Attached you will see a simple script to generate and visualize a 1D random walk and it's resulting outliers.

#R #RStats #RandomWalker #Coding #Programming

library(RandomWalker)
library(dplyr)
library(ggplot2)
library(tidyr)

# Get a random normal walk
rw_tbl <- random_normal_walk(.samp = FALSE, .num_walks = 30)
ci_tbl <- rw_tbl |>
  # Group by walk_number
  group_by(walk_number) |>
  # Calculate the CI for each group
  summarise(
    ci_values = confidence_interval(cum_sum_y)
  ) |>
  # Unnest the ci_values column
  unnest_wider(ci_values) |>
  ungroup() |>
  # Get the minimum lower and maxiumum upper
  summarise(
    lower = min(lower),
    upper = max(upper)
  )

# Which walk numbers are outside of the ci_tbl range
outliers <- rw_tbl |>
  filter(cum_sum_y < ci_tbl$lower | cum_sum_y > ci_tbl$upper) |>
  pull(walk_number) |>
  unique()

rw_tbl |>
  visualize_walks(.pluck = 2) +
  geom_hline(data = ci_tbl, aes(yintercept = lower), linetype = "dashed", color = "red") +
  geom_hline(data = ci_tbl, aes(yintercept = upper), linetype = "dashed", color = "red") +
  # Make the lines of the outliers red and bold
  geom_line(
    data = rw_tbl |> 
      filter(walk_number %in% outliers), 
    aes(x = step_number, y = cum_sum_y, group = walk_number), 
    color = "red",
    linetype = "dashed",
    linewidth = 1)
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-12

If you want to use the C5.0 #algorithm for #Classification you might want to make sure your data is in the right format.

Let my #R package healthyR.ai help you get there.

See an example here: spsanderson.com/healthyR.ai/re

#R #RProgramming #parsnip #C50 #tips #Rtips

library(ggplot2)
library(tibble)

Titanic <- as_tibble(Titanic)

hai_c50_data_prepper(.data = Titanic, .recipe_formula = Survived ~ .)
#> 
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#> 
#> ── Inputs 
#> Number of variables by role
#> outcome:   1
#> predictor: 4
#> 
#> ── Operations 
#> β€’ Factor variables from: tidyselect::vars_select_helpers$where(is.character)
rec_obj <- hai_c50_data_prepper(Titanic, Survived ~ .)
get_juiced_data(rec_obj)
#> # A tibble: 32 Γ— 5
#>    Class Sex    Age       n Survived
#>    <fct> <fct>  <fct> <dbl> <fct>   
#>  1 1st   Male   Child     0 No      
#>  2 2nd   Male   Child     0 No      
#>  3 3rd   Male   Child    35 No      
#>  4 Crew  Male   Child     0 No      
#>  5 1st   Female Child     0 No      
#>  6 2nd   Female Child     0 No      
#>  7 3rd   Female Child    17 No      
#>  8 Crew  Female Child     0 No      
#>  9 1st   Male   Adult   118 No      
#> 10 2nd   Male   Adult   154 No      
#> # β„Ή 22 more rows
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-12

A new function appears,
Tunable parameters it clears,
CRAN release nears.

for tidyAML :)

#R #RStats #CRAN

Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-12

@unusual_whales you aint kidding

Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-12

πŸ“Š Did you know integer(0) can break your R functions? πŸ’‘ Discover best practices for subsetting data frames, handling function returns, and debugging empty vectors. Level up your R programming skills with our detailed guide!

Read more: spsanderson.com/steveondata/po

#RStats #RPogramming #Programming #Data #R #Blog

πŸ“Š Did you know integer(0) can break your R functions? πŸ’‘ Discover best practices for subsetting data frames, handling function returns, and debugging empty vectors. Level up your R programming skills with our detailed guide!

Read more: https://www.spsanderson.com/steveondata/posts/2025-05-12/

#RStats #RPogramming #Programming #Data #R #Blog
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-10

πŸ’‘ The latest update to RandomWalker (v0.3.0) is here! With new features like confidence intervals and subsetting, your random walk analysis just got easier.

Explore the new capabilities: spsanderson.com/steveondata/po

#RStats #Data #RLang #Analysis #Stats

Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-09

πŸ“Š Just released: RandomWalker 0.3.0! Now you can generate random walks in up to 3 dimensions. This is a must-read for R programmers looking to enhance their simulations.

Dive into the details: [spsanderson.com/steveondata/po

#Data #RLang #Stats #RData #Blog #CRAN #RStats #TimeSeries #RandomWalker

30 Random Walks graph, displaying a line graph with the function rw30, showing steps on the x-axis and values on the y-axis. The graph indicates 1 dimension, 100 steps, mu = 0, and sd = 1.A 3-D perspective plot on a light grid shows a pale blue line snaking irregularly through space; the axes are labeled β€œcum_sum_x,” β€œcum_sum_y,” and β€œcum_sum_z,” depicting the cumulative trajectory of a 3-D random walk.2D Random Walk, showing a two-dimensional graph with labeled X and Y positions.A decorative illustration featuring a large, glossy blue letter β€œR” at center, surrounded by flowing translucent ribbon shapes and watercolor-like splashes in shades of blue, teal, and violet on a white background.
Steven P. Sanderson II, MPHstevensanderson@mstdn.social
2025-05-09

A random walk's a funny thing,
Steps of chance, what will they bring?
Through dimensions three,
Or just one, you see,
'Til the final bell does ring!

New version of RandomWalker for #R #blogpost tomorrow :)

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst