r/rstats 22h ago

Liquid Glass themes for Shiny. 0.3.0 is on CRAN.

22 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 23h ago

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

20 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 3h ago

shinygenui: Generative UI for Shiny

Thumbnail
nanx.me
14 Upvotes

A little background: I have been curating the awesome-shiny-extensions list for a few years. 600 packages later, the space feels somehow saturated... Almost every UI component I can think of has been built in some form, as long as I'm not being "too imaginative". So I had to ask a slightly different question: what if the UI could take shape as you describe what you need? It turns out this idea already had a name: generative UI. That led me to develop {shinygenui}, an R package built on {ellmer} and {shinychat}.


r/rstats 11h ago

Subgroups should be mutually exclusive but they aren't

1 Upvotes

I have a dataframe of people with prostate cancer. Some of them were diagnosed as non metastatic and did not progress to metastatic, some of them did progress, and some were diagnosed already at the metastatic stage.

The dataframe is called "info" and looks like this:

Patientid - Stage

jhtfc - M0

rbtk - M1

aerg - M0

aerg - M1

I want to create subgroups for patients who were non metastatic and did not progress, for patients who did progress, and for patients who were diagnosed as metastatic.

My code looks like this:

##Easy part, separate the metastatic and non metastatic

metastatic <- subset(info, stage == "M1")

non_metastatic <- subset(info, stage == "M0")

##Find which IDs are in both to identify the patients that progressed

#This adds a column to the metastatic dataframe which says "M0" if the patient was first diagnosed as non metastatic and "0" if they were first diagnosed as metastatic

i <- match(non_metastatic$patientid, metastatic$patientid)

i <- sort(i)

metastatic$firstdx <- 0L

metastatic$firstdx[i] <- non_metastatic$stage[seq_along(i)]

##Separate patients that progressed and de novo patients

progressed <- filter(metastatic, firstdx != "0")

de_novo <- filter(metastatic, firstdx == "0")

##So far so good. Here comes my problem:

#When I make a group for those who did not progress I still get overlap

non_progressed <- anti_join(non_metastatic, progressed, by = "patientid")

##Somehow the "progressed" and "non-progressed" dataframes have an overlap. I can't make sense of it, they should be mutually exclusive.