gvwilson / tidyblocks

A blocks-based interface for tidy data manipulation and analysis.
Other
82 stars 28 forks source link

Preparing grouped summaries: expectation and replication #427

Open larnsce opened 3 years ago

larnsce commented 3 years ago

I am trying to replicate the output of the following R Code chunk in TidyBlocks:

library(palmerpenguins)
library(dplyr)

penguins %>%
  group_by(species) %>%
  summarise(species_count = n()) 
#> `summarise()` ungrouping output (override with `.groups` argument)
#> # A tibble: 3 x 2
#>   species   species_count
#>   <fct>             <int>
#> 1 Adelie              152
#> 2 Chinstrap            68
#> 3 Gentoo              124

Created on 2020-10-30 by the reprex package (v0.3.0)

I have managed to do so with the following Block:

grafik

I expected the following to work:

grafik

Question 1: Why is the output of summarise not collapsed into 2 columns and 3 rows? It seems counterintutive that a new column is added to the original data instead.

Question 2: How do I name the output object? On the right pane und the tab "Results" I see "unnamed 1" and have not managed to figure out how to change this name.

gvwilson commented 3 years ago
  1. We add a label to show groups so that users can re-group if they want to - given the block metaphor, we couldn't find another visual way to do this. Happy to discuss alternatives.
  2. The "save as" block will save its input under whatever name you choose and pass it to the output unmodified. Screen Shot 2020-11-08 at 7 44 04 AM
larnsce commented 3 years ago

Thanks, should have seen the "Save as" block.

On 1: Could you elaborate on the re-grouping? I am not sure I understand the benefit from a user perspective.

Would you also use of the following code block sequence to get the output that I re-produced above with R? I want to make sure that I am not missing something and would get to this output in a simpler way.