← Back to context

Comment by _Wintermute

1 day ago

In my opinion R should thought of as an unbeatable graphical calculator, but an awful programming language.

The tinyverse collection of packages makes things a lot more sane, IMO:

  penguins <- read_csv("penguins.csv") |>
    na.omit() |>
    select(species, island, bill_length_mm, body_mass_g) |>
    group_by(species, island) |>
    summarize(
      mean_bill_length = mean(bill_length_mm),
      mean_mass = mean(body_mass_g),
      n = n()
    ) |>
    arrange(species, desc(mean_bill_length))
  
  penguins |>
    ggplot(aes(x = species, y = mean_bill_length, fill = island)) +
    geom_col(position = "dodge") +
    labs(
      title = "Mean Bill Length by Species and Island",
      y = "Mean Bill Length (mm)"
    ) +
    theme_minimal()

  • True, but trying to wrap any of that into a function rather than simple scripts makes you delve into the ever-deprecated API for non-standard evaluation.

i would compare base R to basically a shell. meant to be used interactively. okay for small scripts. you can write big programs but it will get weird.