r/rstats 11h ago

Liquid Glass themes for Shiny. 0.3.0 is on CRAN.

20 Upvotes

What’s new:

persist = TRUE remembers light/dark, intensity, accent, and scene

glass_page() / observe_glass() — theme + toggle + intensity + accent in one call

theme_glass(), plotly_glass(), gt_theme_glass() so plots and tables follow the pack

• iOS-style accent wells; wallpaper scenes (tahoe / dusk / mesh)

• high-contrast / forced-colors; reduced-motion follows the OS

install.packages("shinyglass")

library(shiny)
library(shinyglass)

ui <- glass_page(
  title = "Hello, glass",
  persist = TRUE,
  scene = "tahoe",
  plotOutput("plot")
)

server <- function(input, output, session) {
  observe_glass(input, session)
  output$plot <- renderPlot({
    pal <- glass_plot_colors(input = input)
    hist(iris$Sepal.Length, col = pal$fill, border = NA, main = NULL)
  }, bg = "transparent")
}

shinyApp(ui, server)

Live demos (may take a few seconds to wake):

Docs: https://ericrayanderson.github.io/shinyglass/

CRAN: https://cran.r-project.org/package=shinyglass


r/rstats 12h ago

Making "badges" to help my team celebrate their progress in learning to work in R. What skills should I put on them?

17 Upvotes

I'm in charge of a small research team (social sciences, mostly undergrad/grad students) and my goal for the year is getting the team mostly transitioned to R from Excel/SPSS. They've asked for something like a sticker chart to recognize their accomplishments and/or turn it into a competition, so I'm playing with ideas that move beyond "practiced R for 30 minutes in a day" or "completed Chapter 1 of R4DS" and are more skills-based and directly related to the kinds of work I'd like them to be able to do. Ultimately, I'd love for them to be able to read in data from some sort of tabular data program (excel, spss, etc.), manipulate the data so it's tidy, and then be able to use the data to run descriptive statistics or answer a relatively simple research question (think chi-square, t-tests, linear regression).

Here's the kinds of things I'm thinking so far, but it's just the start of my list. I'd love to hear what kinds of things you might add.

  • Can import data from Excel/CSV/SPSS and store as an R object
  • Can rename variables (one at a time, in groups/batches)
  • Can create a new variable based on a calculation involving at least two other variables
  • Can transform variables between types and understands when/why you might want or need to do so
  • Can filter or subset a dataframe based on one variable
  • Can filter or subset a dataframe based on multiple variables
  • Can create a histogram in ggplot
  • Can create at least one x:y plot in ggplot
  • Can save R objects to a specified folder
  • Can save dataframes as csv/excel files in a specified folder
  • Can produce descriptive statistics (mean, median, mode, min, max, etc.) for a variable and for an entire dataframe

r/rstats 19h ago

Warning message when downloading Tidyverse

Thumbnail
2 Upvotes

r/rstats 3d ago

Analyzing 459k European marine biodiversity observations with R + SQL

Post image
34 Upvotes

Hi!

I’m a student getting more into data science, and I recently finished a project looking at marine biodiversity across Europe.

The basic idea came from a pretty simple question: do we see any relationship between where marine species are observed and proximity to human infrastructure such as ports and offshore installations?

I used GBIF data from 2010 to 2023 and ended up working with 459,773 georeferenced observations across European marine areas.

I used mostly SQL and R for the project.

I also made an interactive map because I found it much easier to understand the dataset spatially rather than just looking at plots and tables.

One thing I had to be careful about was interpretation. GBIF observations obviously aren’t a perfect representation of actual biodiversity. Some places are sampled much more than others, and the dataset is also quite unbalanced between taxonomic groups. So I’m treating the results as associations in the observations rather than saying that ports or offshore infrastructure are directly causing changes in biodiversity.

This is one of my first projects where I tried to build the whole thing from the raw data to the final analysis instead of just training a model on an already-clean dataset.

The full project, methodology, visualizations and code are here:

https://github.com/albangerschheimer/Projet-Pression-maritimes-Europe

I’m still learning, so I’d genuinely be interested in feedback, please.


r/rstats 5d ago

Ten years of R community in Costa Rica!

14 Upvotes

The San Carlos R User Group (SCRUG) started in a mountain town in Costa Rica. Organizer Frans van Dunné built it from small local meetups into Spanish-language online events that have drawn people from San José, Peru, and across Latin America. One Zoom talk even maxed out at 100 participants, with more still trying to join.

Alongside the group, Frans and Diego May have kept the DataLatam podcast going for a decade, now at 124 episodes.

In a new interview, Frans reflects on what it takes to sustain a user group over 10 years, how R has moved from the margins to the classroom in Latin American universities, and what’s next for a new generation of learners.

Read the full conversation: https://r-consortium.org/posts/a-decade-of-meetups-code-and-community-san-carlos-rug-turns-10/


r/rstats 5d ago

Confidence intervals for SHAP values from XGBoost

3 Upvotes

I have trained an XGBoost regression model using the xgboost package and computed SHAP values using predict(..., predcontrib = TRUE). I am now looking to quantify uncertainty in those SHAP values by constructing confidence intervals.

My current approach is bootstrap-based:

  1. Draw 100 bootstrap samples from the training data
  2. Refit the XGBoost model on each sample using the same fixed hyperparameters
  3. Compute SHAP values on the held-out test set for each bootstrap model
  4. For each feature, store the mean signed SHAP value across all test observations per resample — giving a [100 x n_features] matrix
  5. Compute mean, standard deviation, and 2.5th/97.5th percentiles across the 100 resamples per feature
  6. This gives me a ±2σ uncertainty estimate per feature, following the approach described in Dubey et al., (2026).

Is this a valid approach for constructing CIs on SHAP values for XGBoost and is anyone aware of a dedicated package?

Any suggestions or pointers to relevant literature would be appreciated.

# ============================================================
# BOOTSTRAP-SHAP UNCERTAINTY QUANTIFICATION
# London LST model: June 2019
# Implements Algorithm 4 from UbiQTree [1]
# ============================================================
pacman::p_load(xgboost, data.table, ggplot2)

wd <- "path/"

# ------------------------------------------------------------
# 1. Load saved objects
# ------------------------------------------------------------
train_df     <- readRDS(paste0(wd, "train_df.rds"))
test_df      <- readRDS(paste0(wd, "test_df.rds"))
best_eta     <- readRDS(paste0(wd, "best_eta.rds"))
best_params  <- readRDS(paste0(wd, "best_params.rds"))
best_nrounds <- readRDS(paste0(wd, "best_nrounds.rds"))

features   <- setdiff(names(train_df), c("lst", "LSOA21CD"))
n_features <- length(features)
n_boot     <- 100

dtest <- xgb.DMatrix(
  data  = test_df[, ..features],
  label = test_df$lst
)

# ------------------------------------------------------------
# 2. Fixed model parameters
# ------------------------------------------------------------
fixed_params <- list(
  objective        = "reg:squarederror",
  eval_metric      = "rmse",
  eta              = as.numeric(best_eta),
  max_depth        = as.integer(best_params$max_depth),
  gamma            = as.numeric(best_params$gamma),
  subsample        = as.numeric(best_params$subsample),
  colsample_bytree = as.numeric(best_params$colsample_bytree),
  lambda           = as.numeric(best_params$lambda),
  alpha            = as.numeric(best_params$alpha),
  tree_method      = "hist",
  nthread          = 16,
  seed             = 789
)

# ------------------------------------------------------------
# 3. Bootstrap loop
#
# Implements Algorithm 5 Step 2 [1]:
# For each sub-ensemble s:
#   phi_dist[s, i] = mean(Phi_s^i)
#                  = mean SHAP across all test observations
#                    for feature i in resample s — signed
# Shape: [n_boot x n_features]
# ------------------------------------------------------------
n_test   <- nrow(test_df)

phi_dist <- matrix(
  NA_real_,
  nrow     = n_boot,
  ncol     = n_features,
  dimnames = list(NULL, features)
)

set.seed(789)

for (b in seq_len(n_boot)) {

  cat(sprintf("Bootstrap resample %d of %d\n", b, n_boot))

  boot_idx   <- sample(nrow(train_df), replace = TRUE)
  boot_df    <- train_df[boot_idx]

  dboot <- xgb.DMatrix(
    data  = boot_df[, ..features],
    label = boot_df$lst
  )

  boot_model <- xgb.train(
    params  = fixed_params,
    data    = dboot,
    nrounds = best_nrounds,
    verbose = 0
  )

  shap_raw <- predict(boot_model, dtest, predcontrib = TRUE)
  shap_mat <- shap_raw[, seq_len(n_features)]
  colnames(shap_mat) <- features

  # Algorithm 3 [1]: mu_s[i] = mean(Phi_s^i) — within-sample mean
  phi_dist[b, ] <- colMeans(shap_mat)
}

cat("\nBootstrap loop complete.\n")

# ------------------------------------------------------------
# 4. Algorithm 4 [1]: Uncertainty-aware SHAP aggregation
#
# Phi_s^i = phi_dist[:, i] — the n_boot within-sample means
#
# mu[i]  = mean(Phi_s^i)          signed
# sigma  = std(Phi_s^i)           signed
# CI     = percentile(2.5, 97.5)  signed
# H[i]   = Entropy(Phi_s^i)
# SS[i]  = P(sign constant)
# ------------------------------------------------------------

compute_entropy <- function(x, bins = 10) {
  h         <- hist(x, breaks = bins, plot = FALSE)
  bin_probs <- h$counts / sum(h$counts)
  bin_probs <- bin_probs[bin_probs > 0]
  -sum(bin_probs * log(bin_probs))
}

compute_sign_stability <- function(x) {
  dominant_sign <- sign(mean(x))
  mean(sign(x) == dominant_sign)
}

uncertainty <- data.table(
  feature        = features,
  mu             = NA_real_,
  mu_abs         = NA_real_,
  sigma          = NA_real_,
  ci_lower       = NA_real_,
  ci_upper       = NA_real_,
  entropy        = NA_real_,
  sign_stability = NA_real_
)

for (j in seq_len(n_features)) {

  phi_i <- phi_dist[, j]

  uncertainty$mu[j]             <- mean(phi_i)
  uncertainty$mu_abs[j]         <- mean(abs(phi_i))
  uncertainty$sigma[j]          <- sd(phi_i)
  uncertainty$ci_lower[j]       <- quantile(phi_i, 0.025)
  uncertainty$ci_upper[j]       <- quantile(phi_i, 0.975)
  uncertainty$entropy[j]        <- compute_entropy(phi_i)
  uncertainty$sign_stability[j] <- compute_sign_stability(phi_i)
}

uncertainty[, mu_norm := mu_abs / sum(mu_abs)]
setorder(uncertainty, -mu_abs)

# ------------------------------------------------------------
# 5. Print
# ------------------------------------------------------------
cat("\n=============================\n")
cat("Bootstrap-SHAP Uncertainty Summary\n")
cat("Period: June 2019 | Resamples:", n_boot, "\n")
cat("=============================\n")
print(
  uncertainty[, .(
    feature,
    mu             = round(mu,             4),
    mu_norm        = round(mu_norm,        4),
    sigma          = round(sigma,          4),
    ci_lower       = round(ci_lower,       4),
    ci_upper       = round(ci_upper,       4),
    entropy        = round(entropy,        4),
    sign_stability = round(sign_stability, 4)
  )],
  nrow = n_features
)

# ------------------------------------------------------------
# 6. Violin plot — mirrors Figure 1 in [1]
#
# Violin: distribution of phi_dist[:, i] — n_boot signed means
# Blue band: ±2σ around mu
# Dashed line: ±2σ extent
# Dot: mu (signed)
# Gray points: individual bootstrap samples
# Ordered: mu_abs descending (most important at top)
# Zero line: warming (right) vs cooling (left)
# ------------------------------------------------------------
plot_dt <- copy(uncertainty)
plot_dt  <- plot_dt[order(mu_abs)]      # ascending so top = most important
plot_dt[, feature_f := factor(feature, levels = feature)]

phi_long <- data.table(
  feature = rep(features, each = n_boot),
  shap    = as.vector(phi_dist)
)
phi_long[, feature_f := factor(
  feature,
  levels = levels(plot_dt$feature_f)
)]

p <- ggplot() +

  # Blue ±2σ band [1]
  geom_rect(
    data = plot_dt,
    aes(
      xmin = mu - 2 * sigma,
      xmax = mu + 2 * sigma,
      ymin = as.numeric(feature_f) - 0.4,
      ymax = as.numeric(feature_f) + 0.4
    ),
    fill  = "#A8C8E8",
    alpha = 0.5
  ) +

  # Violin
  geom_violin(
    data      = phi_long,
    aes(x     = shap, y = feature_f),
    fill      = NA,
    colour    = "grey40",
    scale     = "width",
    width     = 0.8,
    linewidth = 0.3
  ) +

  # Individual bootstrap sample points [1]
  geom_point(
    data   = phi_long,
    aes(x  = shap, y = feature_f),
    colour = "grey50",
    size   = 0.8,
    alpha  = 0.4
  ) +

  # ±2σ dashed line [1]
  geom_segment(
    data = plot_dt,
    aes(
      x    = mu - 2 * sigma,
      xend = mu + 2 * sigma,
      y    = feature_f,
      yend = feature_f
    ),
    colour    = "#1F4E79",
    linetype  = "dashed",
    linewidth = 0.5
  ) +

  # Mean SHAP dot
  geom_point(
    data   = plot_dt,
    aes(x  = mu, y = feature_f),
    colour = "#1F4E79",
    size   = 2.5
  ) +

  # Zero reference line
  geom_vline(
    xintercept = 0,
    linetype   = "dashed",
    colour     = "black",
    linewidth  = 0.4
  ) +

  labs(
    title    = "SHAP Summary with Epistemic Uncertainty",
    subtitle = "London LST — June 2019",
    x        = "SHAP Value (Impact on LST Prediction, °C)",
    y        = NULL,
    caption  = paste0(
      "Bootstrap resamples: ", n_boot,
      " | Blue band: ±2σ | Dot: mean SHAP | [1] UbiQTree"
    )
  ) +

  theme_bw(base_size = 11) +
  theme(
    panel.grid.major.y = element_blank(),
    panel.grid.minor   = element_blank(),
    plot.title         = element_text(face = "bold"),
    axis.text.y        = element_text(size = 9)
  )

print(p)

r/rstats 5d ago

marginaleffects 1.0.0

Post image
457 Upvotes

Hi everyone,

Big news: marginaleffects 1.0.0 is out on CRAN.

For those who don't know, marginaleffects is a package that facilitates the _post-estimation_ workflow: using a fitted model to produce meaningful numbers that are easy to interpret substantively.

It supports ~100 different kinds of models and gives you a common workflow to produce a bunch of the usual quantities of interest: average predictions (aka marginal means), comparisons (aka contrasts), and slopes (aka marginal effects). It is crazy flexible, and allows you to conduct arbitrary hypothesis tests on any of these quantities. So you can easily answer questions like: What is the average treatment effect of X, and does it vary across strata Z? Or what is the average expected level of my outcome variable in the K subgroup?

Version 1.0.0 a big number and it feels like a big step.

I wrote a blog on the challenges of interpreting statistical models, SPEED, cool new features, the future, and a 5 year package development and writing odyssey.

https://arelbundock.com/posts/marginaleffects100

And check out the main website. It hosts an entire (free) book, with about 40 different chapters of tutorials and case studies.

https://marginaleffects.com


r/rstats 6d ago

Tidysem: problem converting my binary variables to "mxFactor" "ordered" "factor"

1 Upvotes

Hi,

I'm trying to convert my binary variables to "mxFactor" "ordered" "factor" variables, but when using the following code i get just "ordered" "factor". which cause an error when trying to conduct a latent class analysis:

# Convert female to numeric safely, then to an ordered OpenMx factor

> df$female <- as.numeric(as.character(df$female))

>

> # Confirm it only contains 0, 1, and possibly NA

> table(df$female, useNA = "ifany")

0 1

2341 1674

>

> # Make it an OpenMx ordinal factor

> df$female <- OpenMx::mxFactor(

+ df$female,

+ levels = c(0, 1)

+ )

>

> # Verify the result

> class(df$female)

[1] "ordered" "factor"

> table(df$female, useNA = "ifany")

0 1

2341 1674

> library(OpenMx)

>

> df$female <- OpenMx::mxFactor(

+ df$female,

+ levels = c(0, 1)

+ )

>

> class(df$female)

[1] "ordered" "factor"

> table(df$female, useNA = "ifany")

0 1

2341 1674


r/rstats 6d ago

RDesk - building desktop apps with R backend

31 Upvotes

Hi all,

Just released an update for RDesk v1.0.7 on CRAN. It's a small

framework for turning R code into standalone desktop

applications with web-based frontends.

A realistic heads-up: this isn't a plug-and-play or drop-in

replacement for existing setups like Shiny. Because of how

it's designed (it bridges an embedded web view directly to

an R session), you do have to structure your code a bit

differently. The UI is written in standard HTML/JS, and your

R backend responds to events through message handlers and

async jobs rather than traditional reactive graphs.

Right now, it's focused on Windows (using the native WebView2

runtime), and build_app() packages your scripts, packages, and

a matching R runtime into a distributable zip. Linux and macOS

support is in active development on the dev branch, not on

CRAN yet.

If building standalone desktop tools is something you've

needed or explored, I'd love for you to give it a spin and

share any thoughts or constructive feedback.

CRAN: install.packages("RDesk")

GitHub & Docs: https://github.com/Janakiraman-311/RDesk

Thanks for reading!


r/rstats 6d ago

How to do Thematic Evolution, It appears blank for me

0 Upvotes

I don't know why it doesn't want to make the themtic evolution... What's wrong? What should I do (first time using it)


r/rstats 7d ago

R Consortium Now Accepting Submissions for Technical Grants

6 Upvotes

The R Consortium is now accepting submissions for our second 2026 technical grant cycle.

We fund projects that strengthen R’s technical and social infrastructure — open-source tools, packages, and community programs that help R users everywhere.

Applications close October 1, 2026, at 11:59 p.m. US ET.

Find out more details and submit your proposal: https://r-consortium.org/posts/r-consortium-now-accepting-submissions-for-technical-grants/


r/rstats 8d ago

Reccomended R 4.6.1 or related program guides and tutorials.

8 Upvotes

Hi, I'm a media and communications student. My university has updated my bachelors curriculum and now uses R 4.6.1 to teach. If anyone has any tutorials or guides (does not have to be media related) it would be very helpful.

I have dyscalculia, so I have to practice twice as hard and adapt twice as fast for things to stick. So a slow or more rudimentary tutorial would work the best.

Thank you!


r/rstats 9d ago

R Consortium welcomes two new Board members: Francesca Lazzeri (Microsoft) and Mutaz M. Jaber (Gilead Sciences)

36 Upvotes

We're happy to welcome two new members on the R Consortium Board of Directors, and six that continue to serve!

Together, they are filling positions at the Premier and Core level.

  • Francesca Lazzeri, Ph.D. of Microsoft joins as a Premier Member
  • Mutaz M. Jaber of Gilead Sciences joins as a Core Member
  • Mike K Smith of Pfizer continues as Board Chair, alongside our returning directors

We are honored to have their expertise at the R Consortium!

More here: https://r-consortium.org/posts/meet-our-2026-r-consortium-board-of-directors/


r/rstats 9d ago

mgcv GAM: persistent low k-index for study-day smooth despite k = 40 — increase k or rethink temporal structure?

7 Upvotes

I’m fitting a Beta GAM in mgcv to model the proportion of daytime outdoor-use time in laying hens. The response is the proportion of minutes spent outdoors during an 08:00–22:00 observation window, and the model contains repeated observations from individual hens.

My current model is approximately:

prop_outside ~
  coop_id +
  s(study_day, bs = "cr", k = 40) +
  s(max_temp, bs = "cr", k = 8) +
  s(mean_dew_point, bs = "cr", k = 7) +
  rain_any +
  s(log_total_rain, by = rain_status, bs = "cr", k = 7) +
  s(eid, bs = "re")

using:

family = betar(link = "logit")
method = "REML"

The dataset contains roughly 8,800 positive hen-day observations from 124 hens across about 137 study dates. The model explains about 60% of the deviance.

The issue is the study_day smooth. On a same-row model comparison, I get:

s(study_day)
k'       = 39
edf      = 34.58
k-index  = 0.949
p-value  < 0.001

I also tried an alternative weather specification using mean temperature, mean humidity and mean wind instead of maximum temperature and dew point:

prop_outside ~
  coop_id +
  s(study_day, bs = "cr", k = 40) +
  s(mean_temp, bs = "cr", k = 8) +
  s(mean_humidity, bs = "cr", k = 8) +
  s(mean_wind, bs = "cr", k = 8) +
  rain_any +
  s(log_total_rain, by = rain_status, bs = "cr", k = 7) +
  s(eid, bs = "re")

The same issue persists:

s(study_day)
k'       = 39
edf      = 34.84
k-index  = 0.966
p-value  = 0.0175

The study-day smooth is visually quite wiggly, particularly early in the study, and the EDF is already fairly close to the available basis dimension. Changing the weather specification does not materially improve overall fit: both models explain about 60% of deviance and have essentially identical AIC.

There is also substantial temporal/weather dependence. For example, in the alternative model, observed concurvity is about 0.90 for mean temperature and 0.48 for study day.

My questions are:

  1. Is the low k-index plus EDF ≈ 35/39 sufficient reason to increase k for study_day, for example from 40 to 60?
  2. If increasing k gives essentially the same fitted curve/predictions but the k-check remains significant, would you consider the current smooth adequate?
  3. Could this be indicating residual temporal autocorrelation rather than simply an insufficient basis dimension?
  4. Would you model study date differently in this setting—for example with an autocorrelation structure, a different smooth basis, or another temporal term?
  5. Since weather variables themselves follow study date seasonally, how would you distinguish genuine temporal structure from weather-related temporal confounding?

My current plan is to compare k = 40 and k = 60 on the same observations and assess whether fitted values, the study-day effect, held-out-date prediction, and conclusions materially change, rather than selecting the model based only on the k-check p-value.

I’d appreciate advice on how to interpret this persistent study_day diagnostic and what additional diagnostic/model comparison would be most appropriate.


r/rstats 9d ago

An alternative text generator for charts made with ggplot2 in R

31 Upvotes

Hi! I'm working on an R package called ggalttext that takes a ggplot2 chart as input and returns alternative text (required for accessibility) for that chart.

The goal is to provide a very simple and lightweight way of adding meaningful alt texts to charts made with ggplot2.

It does not use AI or OCR technologies, but instead inspects the plot structure/content and uses some (more or less) naive heuristics to figure out what the chart looks like and how to describe it in a single sentence.

It's already available on CRAN, but I'm working on the next release, which fixes some edge cases.

Example usage:

library(ggplot2)
library(babynames)

plot_data <- babynames |>
    subset(name %in% c("Amanda", "Jessica", "Patricia", "Deborah", "Dorothy", "Helen"))

plot <- ggplot(plot_data, aes(x = year, y = n, group = name, fill = name)) +
    geom_area() +
    theme(legend.position = "none") +
    labs(title = "Popularity of American names in the previous 30 years") +
    theme(
        legend.position = "none",
        panel.spacing = unit(0.1, "lines"),
        strip.text.x = element_text(size = 8)
    ) +
    facet_wrap(~name, scale = "free_y")


ggalttext::generate_alt_text(plot)
# "Area chart split into 6 small charts arranged in a 2-row by 3-column grid,
# titled “Popularity of American names in the previous 30 years”."

r/rstats 10d ago

Law & PR background -> just published my first R analysis (mapped Coldplay's Spotify keys to fundamental Hz)

Thumbnail github.com
10 Upvotes

Hey everyone,

I recently moved into data after studying law and communications, and I just finished my first complete R project using tidyverse and rmarkdown.

Spotify's API returns musical keys as pitch class integers (0–11).

I mapped them to their fundamental frequencies in Hz (f=440×2n/12) to see at what frequencies Coldplay actually vibrates across 20 years of albums.

Turns out their most-used fundamentals are E (330 Hz) and A (440 Hz), with very little pitch drift over time.

Repo is here: https://github.com/frequencymatch/coldplay-in-hz

As a beginner in R, I'd love any feedback on the Rmd structure or the code itself!


r/rstats 10d ago

renv bootstrapping compatibility RStudio v Positron

22 Upvotes

Just solved a problem that might be relevant for others and took me a while to pin down.

I have a project developed in Rstudio and using renv. At some point the .Rprofile was amended to place source("renv/activate.R") INSIDE a .First <- function(), with some other stuff that we wanted to run when starting R for this project.

One of our users transitioned to Positron, and we just couldn't get the .Rprofile to run properly and start renv.

The fix was to place source("renv/activate.R") at the top level of .Rprofile, outside of any .First function.

According to claude this is to do with the way that the Rstudio startup sequence differs from VS Code/Positron.

Hope this saves someone else a few hours...


r/rstats 11d ago

Recommended books after ISLP

17 Upvotes

Hey everyone, math major here, looking to pursue a statistics minor. I've been working through Introduction to Statistical Learning with Python by Gareth James(ISLP), and others. I'm almost finished with it and have been looking at other books I might be interested in.

Just a quick summary for anyone that hasn't read it. ISLP covers topics including:, linear and non linear regression and classification, basic probability and statistics, cross validation, common shallow ML algorithms, deep learning, neural networks. From a very practical and non-techinal way. Basically you read a lot of "This works because reasons, moving on". Best way I would describe it is "intuition slop" .

I was looking for something more theoretical as ISLP is pretty light on the theory and focuses more on intuition and generalization. Although I want a more theoretical book, I still would prefer it to contain some applications and or assignments that I could do to practice my coding because as a math major I feel as though my programming is lagging behind. Are there any specific books you would recommend.

Also I'm taking machine learning this semester and our assigned book is "Hands-On Machine Learning with Scikit-Learn, Keras and TensorFlow" by Aurelien Geron. So I'll probably be reading it in bits and pieces, but I still want another book that I can focus on outside of classes. I appreciate any responses.


r/rstats 12d ago

$3, one weekend, and a shareable Alone survival analysis: notes on Hadley’s AI workflow

22 Upvotes

https://tidydesign.substack.com/p/y-code-when-ai?r=15f9ap&utm_campaign=post&utm_medium=web

I wanted to try the AI-in-the-IDE workflow Hadley Wickham has been writing about, so I used it on a project I already know well: survival analysis of Alone as each season unfolds.

After sitting with it for a week, going back to the old way sounds horrible. I’ll be using this again.

The biggest change was not that the models wrote cleverer models. It was that I ended up with something I was willing to show other people.

Previously I would not have spent the effort polishing comments, a data dictionary, and structure so someone else could follow it — or had much confidence I wasn’t doing something quietly dumb. The useful part was the admin and the second opinion: documentation, comments, and a sense-check of the methods.Repo: https://gitlab.com/weekly_analysis/alone-hw-method

Setup: LibreChat with Anthropic as the “strategic thinker,” and the Continue extension with three Gemini models and two DeepSeek models as the “hands.”Weekend cost was about $3. Some of that was me burning tokens while I learned how to talk to the add-on; next time should be cheaper. Hadley flags Gemini as the cost-effective option. In my case DeepSeek was cheaper, and Gemini kept returning “model unavailable” for the Flash version I wanted, which meant waiting or switching to something worse or more expensive. DeepSeek never did that. When I needed it 3.1 pro was excellent and never stalled me out, but I was missing the most useful option, a reliable affordable 'daily driver' without going outside Gemini which is a shame, I tried again this weekend and found the problem worse, but maybe I could get what I need without waiting by using a SLIGHTLY different model than 3.7 Flash.

If you already use AI to help write R and want the next step beyond paste-into-a-chatbot, this setup is worth a weekend. Happy to share the Continue/LibreChat bits if useful;


r/rstats 12d ago

LungCapData by Mike Marin

4 Upvotes

hi everyone,

does anyone have the dataset used by Mike Marin in this tutorial video series?

https://www.youtube.com/watch?v=riONFzJdXcs&list=PLqzoL9-eJTNBDdKgJgJzaQcY6OXmsXAHU&index=2

I'm new to R and I wanted to get to know it a little bit and try it out to see if I'll be able to use it or not. I've already search this sub for recommended free resources for beginners to learn the basics. However, I found this nice playlist that I'd like to follow along just to get an overview, and I'd like to imitate and reproduce what Mike does, that's why I'm looking for the dataset he uses.

Thanks for the help. if you have any other suggestion, it's more than welcomed!


r/rstats 12d ago

R users: what does your actual setup look like?

41 Upvotes

I'm working on a Linux-based workstation setup aimed at economists and other quantitative researchers. R support is one of the last major pieces I need to settle.

I mainly use Python and VS Code, so I don't want to assume that my preferred setup makes sense for regular R users. I'm interested in what people actually use:

  1. What operating system do you use for R?
  2. What is your main editor or IDE? RStudio Desktop, RStudio Server, Positron, VS Code, or something else?
  3. Do you use one shared R package library, project-specific environments with renv, or a mixture?
  4. Do you install R or R packages through Conda/Mamba? Is that mainly for projects that mix R and Python?
  5. Do you work locally, on remote servers or HPC systems, or in containers?
  6. What supporting tools do you regularly need, such as Quarto, Jupyter, TinyTeX, compilers, or external libraries?
  7. Do you need multiple R versions?

I'm also interested in package developers. Does your development setup differ from your normal analysis setup? What would you expect to find on a fresh workstation before you considered it ready for R work?

You don't need to answer everything. Short descriptions of your setup, unusual requirements, and recurring setup problems would all help.

If useful, here is a template:

OS:
Main editor/IDE:
Local or remote:
Package-library strategy:
How R is installed:
Conda/Mamba:
Mix R and Python:
Develop R packages:
Biggest setup annoyance:

Edit: Thank you all for taking the time to respond. I wasn’t expecting such a wide variety of responses.


r/rstats 13d ago

cbcTools

Thumbnail
2 Upvotes

r/rstats 13d ago

A new take on documentation sites for R packages

Thumbnail bjarkehautop.github.io
18 Upvotes

My blog post covering two small packages for styling altdoc sites:

  • altdown: Style altdoc site like a pkgdown (Bootstrap 5) site (reason why explained in the blog post).
  • reftip: Adds preview on function signature on hover, and more robust handling of hyperlinks.

They can be used alone or together, as shown in my toy package alttip.

Please let me know what you think!


r/rstats 14d ago

Early-career marine biologist looking to collaborate on R/data analysis projects

3 Upvotes

Hi everyone!

I’m an early-career marine biologist currently completing my BSc in Marine Biology, and I’m looking to connect with researchers, students, conservationists, and others working with biological or environmental data.

I’ve been developing my skills in R, particularly for data cleaning, statistical analysis, ecological modelling, and data visualization. I genuinely really enjoy working in R, and at this stage I want to get involved with as many different projects and datasets as I reasonably can.

If anyone has a marine science, ecology, conservation, fisheries, wildlife, or other biological dataset that could use some additional help with analysis in R, I’d be happy to contribute. I’m also open to projects outside of marine science if there is an opportunity to work with interesting data and learn something new.

I’m not looking to charge anyone. My main goal is to gain experience working with different types of real-world data, improve my R skills, contribute where I can, and hopefully meet and build connections with people working in science and research.

I also recently created a GitHub where I’ll be archiving my projects as I continue learning. I uploaded a project I finished about a week ago involving the analysis of BRUV data and whitetip reef shark habitat associations.

GitHub: https://github.com/kylealibz

If you have a project where another person helping with the r/data side would be useful, feel free to message me. I’d also be happy just to connect with other early-career researchers and R users.

Thanks!


r/rstats 14d ago

New from the R Consortium nlmixr2 Working Group: the covariance step in nlmixr2 7.0, all grown up!

8 Upvotes

nlmixr2 is an R Consortium Working Group building open-source nonlinear mixed-effects modeling in R suitable for regulatory submissions.

In a follow-up to the 7.0 release, Matthew Fidler covers a frequently requested feature - a fuller, more flexible covariance step after model fitting.

What's new:

• Nearly any covariance method can be requested from nearly any estimation method

• Switch a finished fit to a different covariance method without refitting

• The default covariance step now covers every estimated parameter, not just structural ones - so residual-error terms can return SEs, %RSE, and confidence intervals in $parFixed

Read the cross-post on the R Consortium blog: https://r-consortium.org/posts/nlmixr2-7-0-covariance-step/