fork download
  1. library(dplyr)
  2.  
  3. # Sample dataset
  4. df <- data.frame(Name = c("Alice", "Bob", "Charlie", "David"),
  5. Age = c(25, 30, 35, 40),
  6. Score = c(90, 85, 88, 92))
  7.  
  8. # Using pipes
  9. df %>%
  10. filter(Age > 30) %>% # Keep only Age > 30
  11. select(Name, Score) %>% # Select columns Name and Score
  12. summarize(avg_score = mean(Score)) # Compute average score
  13.  
Success #stdin #stdout #stderr 0.76s 52844KB
stdin
Standard input is empty
stdout
  avg_score
1        90
stderr
Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union