Assignment_2
Assignment_2
20221CSD0111
5CSD02
Assignment 2:
1. Data Visualizations with ggplot2 with examples
CODE
# install.packages("ggplot2")
library(ggplot2)
Values = c(rnorm(10, mean = 5), rnorm(10, mean = 10), rnorm(10, mean = 20), rnorm(10,
mean = 15)),
# Scatter plot
geom_point(size = 3) +
geom_line() +
geom_point() +
theme_minimal()
theme_minimal()
# Histogram
theme_minimal()
# Box plot
geom_boxplot() +
theme_minimal()
# Density plot
geom_density(alpha = 0.5) +
theme_minimal()
# Violin plot
geom_violin() +
theme_minimal()
# Facet plot
facet_wrap(~ Category) +
theme_minimal()
CONSOLE
library(ggplot2)
+ Values = c(rnorm(10, mean = 5), rnorm(10, mean = 10), rnorm(10, mean = 20), rnorm(10, mean = 15)),
+ Score = c(sample(1:100, 40))
+)
+ geom_point(size = 3) +
+ theme_minimal()
+ geom_line() +
+ geom_point() +
+ theme_minimal()
+ theme_minimal()
> # Histogram
+ theme_minimal()
+ theme_minimal()
+ geom_density(alpha = 0.5) +
+ theme_minimal()
+ geom_violin() +
+ theme_minimal()
+ facet_wrap(~ Category) +
+ theme_minimal()