Create a data frame of 10 students’ names, subject and marks. Display the summary of subject and marks. Plot and interpret a boxplot for subject and marks in R.
Team Answered question April 8, 2024
# Create data frame of students' information students <- data.frame( Name = c("John", "Emily", "Michael", "Sophia", "Daniel", "Olivia", "William", "Ava", "James", "Isabella"), Subject = rep(c("Math", "Science", "English"), each = 10), Marks = sample(60:100, 30, replace = TRUE) # Generating random marks for demonstration ) # View the data frame View(students) # Display summary statistics for subjects and marks summary(students$Subject) summary(students$Marks) # Plot boxplot for subjects boxplot(Marks ~ Subject, data = students, main = "Boxplot of Marks by Subject", xlab = "Subject", ylab = "Marks")
Name | Subject | Marks |
---|---|---|
John | Math | 75 |
Emily | Math | 73 |
Michael | Math | 99 |
Sophia | Math | 65 |
Daniel | Math | 68 |
Olivia | Math | 92 |
William | Math | 100 |
Ava | Math | 71 |
James | Math | 91 |
Isabella | Math | 87 |
John | Science | 75 |
Emily | Science | 86 |
Michael | Science | 100 |
Sophia | Science | 100 |
Daniel | Science | 96 |
Olivia | Science | 65 |
William | Science | 84 |
Ava | Science | 76 |
James | Science | 95 |
Isabella | Science | 63 |
John | English | 80 |
Emily | English | 93 |
Michael | English | 62 |
Sophia | English | 91 |
Daniel | English | 87 |
Olivia | English | 62 |
William | English | 71 |
Ava | English | 85 |
James | English | 91 |
Isabella | English | 91 |
Team Answered question April 8, 2024