gk231192

Untitled

Jun 5th, 2024
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.52 KB | None | 0 0
  1. library(dplyr)
  2.  
  3. # Example dataset
  4. data <- data.frame(
  5.   Age = c(25, 45, 35, 40),
  6.   Income = c(50000, 100000, 75000, 50000),
  7.   Education = c(12, 16, 14, 16),
  8.   Gender = c("Female", "Male", "Female", "Male")
  9. )
  10.  
  11. # Slicing data by Gender
  12. data_male <- filter(data, Gender == "Male")
  13. data_female <- filter(data, Gender == "Female")
  14.  
  15. # Dicing data to view Income and Education of Males
  16. data_male_income_education <- select(data_male, Income, Education)
  17.  
  18. # Display the sliced and diced data
  19. print(data_male_income_education)
Add Comment
Please, Sign In to add comment