How to creat a summary() table ?

Hello
Is it possible to have a table with the summary() of all my station in each area ?

df <- tribble(
  ~Area, ~station, ~depth, ~Temp, 
  "A1","St1",10, 2.5,
  "A1","St1",20, 2.8, 
  "A1","St1",30, 2.6, 
  "A1","St2",10, 2.6,  
  "A1","St2",20, 2.48, 
  "A1","St2",30, 2.54, 
  "A2","St3",10, 2.8, 
  "A2","St3",20, 2.74,  
  "A2","St3",30, 3.05,  
  "A2","St4",10, 3.18,  
  "A2","St4",20, 1.05,  
  "A2","St4",30, 2.06, 
  "A3","St5",10, 1.26,  
  "A3","St5",20, 3.15,  
  "A3","St5",30, 2.87,  
)

I can have the summary for one station doing this :

df %>% filter(Area == "A1" & Station == "St1") %>% summary()

But in my originally dataset I have several area and station and I can't just do this for only one station each time..

I am not quite sure what you are looking for but summerize in the dplyr package, a component of the tidyverse package may do what you want.

Here is a short example.

library(dplyr)
df %>% group_by(Area, station) %>% summarise(mean = mean(depth), sd = sd(depth))
3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.