Finally, #dplyr functionality I've been hacking through small functions for about a decade and a half: https://dplyr.tidyverse.org/reference/recode-and-replace-values.html

#rstats

Recode and replace values — recode-and-replace-values

recode_values() and replace_values() provide two ways to map old values to new values. They work by matching values against x and using the first match to determine the corresponding value in the output vector. You can also think of these functions as a way to use a lookup table to recode a vector. Use recode_values() when creating an entirely new vector. Use replace_values() when partially updating an existing vector. If you are just replacing a few values within an existing vector, then replace_values() is always a better choice because it is type stable and better expresses intent. A major difference between the two functions is what happens when no cases match: recode_values() falls through to a default. replace_values() retains the original values from x. These functions have two mutually exclusive ways to use them: A formula-based approach, i.e. recode_values(x, from1 ~ to1, from2 ~ to2), similar to case_when(), which is useful when you have a small number of cases. A vector-based approach, i.e. recode_values(x, from = from, to = to), which is useful when you have a pre-built lookup table (which may come from an external source, like a CSV file). See vignette("recoding-replacing") for more examples.

#Rstats #dplyr #ducdkb community extension by ChanYub Park Use dplyr synthax in #duckdb duckdb.org/community_ex...
It's not going to accept it, but in a good world, it would. #dplyr #RStats

Na #PythonCerrado2025, tivemos ontem um excelente tutorial do Lucas Marcondes Pavelski https://github.com/lucasmpavelski.

Aprendemos sobre #R, #tidyverse, #reticulate, várias ferramentas essenciais como #ggplot2 e #dplyr, vendo na prática como aplicá-las. Foco na ponte #Python <-> R.

Tudo novidade pra mim, vieram várias ideias interessantes de análises e plots.

#PythonCerrado

I recently saw a kind of stacked donut/pie chart that visualized nested count data (e.g. a sample description with two relevant categories, like favorite ice cream and gender) and wondered how I'd do that in #rstats.

So, if you ever want to make a plot like this, here's the #ggplot2 and #dplyr code: https://gist.github.com/Kudusch/577b6f07c686a64a3aace685fd9f3bee

This wouldn't work well with too many categories and pie charts in general aren't optimal, but for this specific kind/shape of data, I think it works well enough.

Hey #RStats hivemind, can someone sanity check me?

for some reason filtering with a value assigned to 'x' isn't working here (I was trying to make a dummy dataset for an lapply + ggplot problem I'm having, and instrad have bumped into this weird inconcistency).

df <- data.frame(name = c("delta^13*C", "delta^13*C", "delta^18*O", "delta^18*O"),
x = c(1,1, 2, 2),
y = c(1,3, 5, 4))

x <- "delta^13*C"

df %>%
filter(name == x)

# [1] name x y
# <0 rows> (or 0-length row.names)

df %>%
filter(name == "delta^13*C")

# name x y
# delta^13*C 1 1
# delta^13*C 1 3

#dplyr

I've talked about creating data.frames and tibbles before, but it is an important topic so I have covered it again. This time specifically from the perspective of creating them from vectors. Post: www.spsanderson.com/steveondata/... #R #RStats #tibble #dplyr #tidyverse #dataframe #baseR #blog

# objetivo: Simulación de 100 agentes durante 30 días
# - Cada agente puede estar en 3 estados
# - Cada estado tiene diferentes atributos

# salidas : Tablas de frecuencia de frecuencias de 3 vias:
# - Combinación de estados de 100 agentes cada dia

#Rstats #janitor #dplyr #Flisol #SoftwareLibre

I remember someone mentioning in this network a #R package that generates flowcharts from #dplyr filter/select statements (in chunks) with observations that were kept and removed. I lost this link, I wonder if I am making this memory, or it actually exists.
Día 8 | Distribuciones – Histograma | #30DayChartChallenge. | Visualización hecha usando R con los paquetes #ggplot2, #dplyr, #patchwork, #sf, #ggtext, #showtext, #raster, #exactextractr, #ggscale y #scales.