teunbrand

@teunbrand@fosstodon.org

This profile is from a federated server and may be incomplete. Browse more on the original instance.

teunbrand, to random

Have to output a bunch of dense scatterplots to PDF/SVG, but don't want the filesize to bloat with thousands of symbols to draw the points?

Learn from my mistakes instead of making your own:

geom_point <- function(...) {  
 ggrastr::rasterise(ggplot2::geom_point(...), dpi = 300)  
}  

#rstats

teunbrand,

@nicolaromano There is already a ggrastr::geom_point_rast(). My use case was 'suddenly collaborators want all plots ever made for a project in PDF' for a few notebooks consisting mostly of EDA scatterplots. I did not have the patience to wrap every geom_point() individually :)

teunbrand, to random

And one of the first new guide extensions is live on CRAN: the curved text of {geomtextpath} on coord_radial() ^_^

library(geomtextpath)

ggplot(mpg, aes(class, displ)) +  
 geom_boxplot(staplewidth = 0.5) +  
 coord_radial() +  
 guides(theta = "axis_textpath")  

teunbrand, to random
teunbrand, to random

I'm excited for the new ggplot2 version coming up that I helped out with. So I thought a fun game might be to post a plot every day and people can guess what the new thing is. No cheating by looking at the NEWS.md file!

Let's start with an easy one

teunbrand,

And for today's guess the new thing in ggplot2:

teunbrand,

Today's guess the new thing are these boxplots.

teunbrand,

I hope you all don't see through my deception today

teunbrand,

This one is maybe too subtle, so I'll give the hint that the new thing is happening in the upper-left quadrant (9 o'clock - 12 o'clock).

teunbrand,

Alright, yesterday's plot was difficult to see, as nobody has guessed the new thing. The new thing was that polygons are closed before being deformed by coords.

To make up for the difficulty yesterday, please enjoy today's new thing:

teunbrand,

Yesterday's plot had a few good guesses, but the new thing is that the fill aesthetic can now accept patterns in most geoms.

As for today's guess the new thing, take a gander at this violin plot:

teunbrand,

In today's edition of 'guess the new thing', we have the plot below:

teunbrand,

Yesterday's thing was the minor ticks at the axes.

For 'guess the new thing' of today, we have the following plot:

teunbrand,

The previous plot showed off the new guides in multiple locations thing.

For you daily dose of mtcars, please have a guess at the new thing in this plot:

jadeynryan, to random

A few days ago, @njtierney , @adamhsparks , and @milesmcbain reviewed {soils} in a livestream. {soils} is a WIP package for generating parameterized reports.

Throughout the entire session, my brain was exploding 🤯 with all the nuggets of wisdom, tips & tricks, and best practices.

I wrote up my thoughts, reflections, and notes in this quick blog post.

https://jadeyryan.com/blog/2024-01-22_package-review/

teunbrand,

@jadeynryan @njtierney @adamhsparks @milesmcbain
Regarding the ggtern thing; ggtern essentially reimplements some interior parts of ggplot2 and for that reason overwrites ggplot2's methods. I get why this is done, e.g. x and y are hardcoded position aesthetics, but I wouldn't encourage other developers to take the same approach.

teunbrand, to random

I might have fallen in love with the switch() function. Such a versatile little bugger.

Consider this abomination:

 if (x %in% c("foo", "bar")) {  
 "foobar"  
 } else if (x == "qux") {  
 "quux"  
 } else {  
 "nope"  
 }  

and then this absolute delight:

switch(x, foo = , bar = "foobar", qux = "quux", "nope")  
teunbrand,

As I've been working on legends and axes and stuff, it just makes a lot of things so clear. The justification of legend text used to be an outright horror. Now, that logic could hardly be any clearer:

text <- switch(  
 text_position,  
 top = element_text(hjust = 0.5, vjust = 0.0),  
 bottom = element_text(hjust = 0.5, vjust = 1.0),  
 left = element_text(hjust = 1.0, vjust = 0.5),  
 right = element_text(hjust = 0.0, vjust = 0.5)  
)  
teunbrand, to random

folks who switched from notebook/rmd/qmd oriented workflows to {targets}, how did you transition? Do you just precompute files with {targets} and then use these in your notebooks? Is rendering a notebook in itself a target? How do you do EDA now versus then?
I find it hard to adapt my analysis mindset to the targets framework

teunbrand,

@brodriguesco Ah yes this is helpful for grasping the outline of it. So: yes, you precompute files and yes rendering a notebook is in itself a target. So let's say you try 3 approaches to a problem and find a satisfactory one, you just end up with 2-leaf nodes in targets instead of letting them die in the notebook?

teunbrand,

@njtierney Right so I/O and other standardisable tasks should stay in targets? How do you deal with 'due diligence' tasks that you investigate but end up not using for your final goal? Just prune your targets in the end or you keep them around somewhere?

eddelbuettel, to random
@eddelbuettel@mastodon.social avatar

Dang. %||% coming to base R in R 4.4.0 next April.

teunbrand,

@ERDonnachie @eddelbuettel

To express the thought 'if A is null, then B; if B is also null, then C', the following:

A %||% B %||% C

Is easier to follow and more succinct than the alternatives:

if (is.null(A)) if (is.null(B)) C else B else A

or

if (!is.null(A)) A else if (!is.null(B)) B else if (!is.null(C)) C

teunbrand,

@johnmackintosh @ERDonnachie @eddelbuettel Wasn't too familliar with coalesce() but that seems more like fill behaviour for vectors, whereas %||% is more of a non-vectorised, object-wise operation, if that makes sense.

teunbrand, to random

Do any gurus happen to know about a package function that does the 2D equivalent of run length encoding?

The idea is for a matrix like the following...

> m <- matrix(c(1,1,2,1,1,2,2,2,1), 3, 3)
> m
[,1] [,2] [,3]
[1,] 1 1 2
[2,] 1 1 2
[3,] 2 2 1

...find (the positions of) rectangles with the same value. For example the first 'run' is m[1:2, 1:2] in this case, the second m[1:2, 3], third m[3, 1:2] and last m[3, 3].

teunbrand,

@Mehrad For my use case probably rows should get priority over columns, so the first example should be m[1, 1:2], m[2, 1] and m[2, 2]. The second example might be m[1, 1:2], m[1, 3], m[2, 1], m[2, 2:3], m[3, 1:2] and m[3, 3].

teunbrand, to random

I don't want to sound ungrateful, but what happened yesterday that made people suddenly interested in a definitely-not-ready-for-proper-use repo of mine? Anyway, thanks for the interest!

teunbrand,

@grrrck @Lluis_Revilla It's over at https://github.com/teunbrand/gguidance, but the ggplot2 version it depends on isn't released yet 🤷

  • All
  • Subscribed
  • Moderated
  • Favorites
  • anitta
  • InstantRegret
  • mdbf
  • ngwrru68w68
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • osvaldo12
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • DreamBathrooms
  • JUstTest
  • tacticalgear
  • ethstaker
  • provamag3
  • cisconetworking
  • tester
  • GTA5RPClips
  • cubers
  • everett
  • modclub
  • megavids
  • normalnudes
  • Leos
  • lostlight
  • All magazines