Juan Luis Herrera Cortijo
banner
jl-herrera-cortijo.bsky.social
Juan Luis Herrera Cortijo
@jl-herrera-cortijo.bsky.social
R Tip: Use `.by` in `dplyr::mutate()` for group-specific transformations without `group_by()`. Just:

df %>% mutate(new_var = mean(value), .by = group)

No extra grouping or ungrouping needed! Learn more:

www.linkedin.com/pulse/enhanc...

#RStats #DataScience
Enhancing Data Transformations in R with the .by Argument in dplyr::mutate
Introduction R’s dplyr package has long been a powerhouse for data manipulation, providing intuitive, pipeline-friendly verbs for common data wrangling tasks. Among these, mutate() stands out for its ...
www.linkedin.com
December 11, 2024 at 5:55 AM
R Tip: Keep your R script clean with `local()`. It runs code in a temporary environment so variables don’t pollute the global workspace. Perfect for quick isolation without creating a separate function! Learn more: www.linkedin.com/pulse/levera...

#RStats #DataScience
Leveraging local() in R Scripts for Cleaner and More Maintainable Code
Introduction When working with R scripts, it’s common to load data, define variables, or run computations that produce intermediate results. As your code base grows, you might find the global environm...
www.linkedin.com
December 6, 2024 at 7:00 AM
R Tip: Use the `.by` argument in `dplyr::summarise()` to group data without `group_by()`! 🚀 Example:

df %>% summarise(mean_value = mean(value), .by = group)

This makes your code cleaner and more concise! ✨

#RStats #DataScience

www.linkedin.com/pulse/enhanc...
Enhancing Data Summarization in R with the .by Argument in dplyr::summarise
Introduction Data summarization is a fundamental step in data analysis, allowing us to condense large datasets into meaningful insights. The dplyr package in R has long been a go-to tool for data mani...
www.linkedin.com
December 5, 2024 at 5:18 PM
R Tip: Manage internal state in your R packages using an internal environment named `"the"`! 🔒 Create it `the <- new.env(parent = emptyenv())` to store internal data without exposing it to users. Clean and robust package namespace! Inspired by Wickham & Bryan's "R Packages" 📚 #RStats #DataScience
December 4, 2024 at 6:35 AM
R Tip: Embrace the modern lambda syntax `\(x)` for anonymous functions! 🚀 The old `~ .` syntax is deprecated and maintained only for backward compatibility. Using `\(x) x^2` in `purrr::map()` makes your code clearer and more intuitive. Happy coding! 🎉 #RStats #DataScience
December 3, 2024 at 6:47 AM
R Tip: Choose the right purrr function! 🛠️

- Use `map(data, func)` to transform and return new data.
- Use `modify(data, func)` to change elements in-place.
- Use `walk(data, func)` for side effects, returning the original data invisibly.

Enhance your functional programming! 🚀

#RStats #DataScience
December 2, 2024 at 6:54 AM
R Tip: Handle `NULL` values easily with `rlang`'s `%||%` operator! ✨ It returns the left value if it's not `NULL`, otherwise the right value. Example: `result <- value %||% default` assigns `value` if available, or `default` if `value` is `NULL`. A concise way to set defaults! #RStats #DataScience
December 1, 2024 at 4:49 AM
R Tip: Control where new columns appear using `.before` and `.after` in `dplyr::mutate()`! 🛠️ Place your new variable exactly where you want by specifying column names or positions.

df %>% mutate(new_var = x + y, .before = "x")

Precise control over your data frame structure! 🎯

#RStats #DataScience
November 30, 2024 at 10:16 AM
R Tip: Enhance your ggplot2 visuals with `ggnewscale::new_scale()`! 🎨 Use `new_scale()` to add multiple color or fill scales to a single plot. This allows different geoms to have their own separate color mappings. Elevate your data visualizations! 📊✨ #RStats #DataViz
November 30, 2024 at 9:05 AM
R Tip: Speed up your text writing with `brio::write_lines()`! 🚀 Unlike `base::writeLines()`, `brio::write_lines()` writes UTF-8 encoded text with consistent line endings across all platforms. Ideal for cross-platform scripts and handling special characters! 🌐✍️ #RStats #DataScience
November 28, 2024 at 4:35 AM
R Tip Thread: Master the .keep argument in dplyr::mutate() for cleaner data frames! 🧹
[1/5]The .keep parameter in dplyr::mutate() lets you control which variables are retained after mutation. This can simplify your data frames and make your code more efficient. Let's explore it! #RStats #DataScience
November 27, 2024 at 2:26 PM
Reposted by Juan Luis Herrera Cortijo
Quarto 1.6 is out! 🎉 Download it here: quarto.org/docs/download/

Quarto 1.6 supports unified branding across formats, updates to RevealJS, a new shortcode to reorder content, a landscape page block, and more. Blog post: quarto.org/docs/blog/po...
Quarto 1.6 – Quarto
Quarto 1.6 supports unified branding across formats, updates to RevealJS, a new shortcode to reorder content, a landscape page block, and more. There are also a couple of breaking changes that will af...
quarto.org
November 25, 2024 at 8:40 PM
R Tip: Clean your data effortlessly with `purrr::keep()` and `purrr::discard()`! 🧹 Use `keep(my_list, is.numeric)` to retain only numeric elements, or `discard(my_list, is.null)` to remove `NULL`s. Streamline your data processing pipelines! #RStats #DataScience
November 26, 2024 at 3:52 AM
R Tip Thread: Mastering `rlang::dots_list()` and `.homonyms` for flexible function arguments! 🚀
November 25, 2024 at 6:15 AM
Reposted by Juan Luis Herrera Cortijo
Check out our video on parameterized report automation. Generate customized data-driven reports in minutes with Python!
Part 2 of a multi-part series on Quarto & Python.
Subscribe to Posit's YouTube channel to get them all.
youtu.be/_kjs_u3Ctt4
#Python #pydata #quarto #DataScience
Generate hundreds of reports in minutes with Python & Quarto! (Parameterized report automation)
YouTube video by Posit PBC
youtu.be
November 22, 2024 at 5:43 PM
Reposted by Juan Luis Herrera Cortijo
Introducing the mall package for running multiple LLM predictions against a data frame in #RStats or #Python!

mall is inspired by the SQL AI functions offered by vendors such as Databricks and Snowflake.

Learn more in this blog post by @theotheredgar.bsky.social: blogs.rstudio.com/ai/posts/202...
Posit AI Blog: Introducing mall for R...and Python
We are proud to introduce the {mall}. With {mall}, you can use a local LLM to run NLP operations across a data frame. (sentiment, summarization, translation, etc). {mall} has been simultaneusly rele...
blogs.rstudio.com
November 21, 2024 at 3:06 PM
R Tip: Automate your report generation by inserting images into Word docs with `officer::body_add_img()`! 🖼️ Use `body_add_img(doc, src = here::here("path/to/image.png"), pos = "after", width = 6, height = 4)` to add images seamlessly. Perfect for dynamic document creation! #RStats #DataScience
November 22, 2024 at 5:48 AM
Reposted by Juan Luis Herrera Cortijo
Want to create websites with #Quarto?

@cwick.co.nz shows how to:

1. Start: www.youtube.com/watch?v=l7r2...
2. Add pages: www.youtube.com/watch?v=k65E...
3. Customize: www.youtube.com/watch?v=pAN2...
4. Add listings: www.youtube.com/watch?v=bv_C...

Great for #RStats, #Python, #JuliaLang folks!
November 20, 2024 at 3:07 PM
R Tip: Generate unique identifiers effortlessly with `uuid::UUIDgenerate()`! 🔑 Use `UUIDgenerate()` to create universally unique IDs for your data rows, ensuring no duplicates. Perfect for merging datasets or tracking records! #RStats #DataScience
November 21, 2024 at 4:23 AM
Reposted by Juan Luis Herrera Cortijo
We are thrilled to announce that we have a new @posit.co Starter Pack, thanks to @jeremy-data.bsky.social!

Find and follow Posit people here: go.bsky.app/RxAPkGi
November 19, 2024 at 10:17 PM
R Tip: Streamline your spatial joins with `sf::st_join()` and `sf::st_within()`. 🌐 Use `st_join(points, polygons, join = st_within, left = FALSE)` to merge only the points within polygons, returning just the matching features. Efficient and tidy spatial analysis! #RStats #GIS #DataScience
November 20, 2024 at 4:40 AM
Reposted by Juan Luis Herrera Cortijo
We’re excited to announce that S7 v0.2.0 is on CRAN!

S7 is a new object-oriented programming (OOP) system for #RStats, collaboratively designed to supersede both S3 and S4.

Shout out to the hard work of @t-kalinowski.bsky.social!

Learn more in the blog post: www.tidyverse.org/blog/2024/11...
S7 0.2.0 - Tidyverse
S7 is a new package that simplifies object-oriented programming (OOP) in R. It combines the simplicity of S3 with the structure of S4 to create a clearer system that's accessible to everyone.
www.tidyverse.org
November 12, 2024 at 3:22 PM
R Tip: Simplify your string formatting with `glue::glue()`! 📊 Instead of multiple `paste()` functions, use `glue('Hello {name}, your score is {score}')` to embed variables directly into strings. Clean and readable code! #RStats #DataScience
November 19, 2024 at 6:45 AM