Lattice Package implemented in R
library("lattice")
my_data <- iris
head(my_data)
xyplot(Sepal.Length ~ Petal.Length, data = my_data)
xyplot(Sepal.Length ~ Petal.Length, group = Species,
data = my_data, auto.key = TRUE)
# Show points ("p"), grids ("g") and smoothing line
# Change xlab and ylab
xyplot(Sepal.Length ~ Petal.Length, data = my_data,
type = c("p", "g", "smooth"),
xlab = "Miles/(US) gallon", ylab = "Weight (1000 lbs)")
xyplot(Sepal.Length ~ Petal.Length | Species,
group = Species, data = my_data,
type = c("p", "smooth"),
scales = "free")
# Basic 3D scatter plot
cloud(Sepal.Length ~ Sepal.Length * Petal.Width,
data = iris)
# Color by groups; auto.key = TRUE to show legend
cloud(Sepal.Length ~ Sepal.Length * Petal.Width,
group = Species, data = iris,
auto.key = TRUE)
# Basic box plot
bwplot(len ~ dose, data = ToothGrowth,
xlab = "Dose", ylab = "Length")
# Violin plot using panel = panel.violin
bwplot(len ~ dose, data = ToothGrowth,
panel = panel.violin,
xlab = "Dose", ylab = "Length")
ToothGrowth$dose<- as.factor(ToothGrowth$dose)
head(ToothGrowth$dose)
# Basic dot plot
dotplot(len ~ dose, data = ToothGrowth,
xlab = "Dose", ylab = "Length")
# Basic stip plot
stripplot(len ~ dose, data = ToothGrowth,
jitter.data = TRUE, pch = 19 , xlab = "Dose", ylab = "Length")
# Box plot
bwplot(len ~ supp | dose, data = ToothGrowth,
layout = c(3, 1),
xlab = "Dose", ylab = "Length")
# Violin plot
bwplot(len ~ supp | dose, data = ToothGrowth,
layout = c(3, 1), panel = panel.violin,
xlab = "Dose", ylab = "Length")
# Dot plot
dotplot(len ~ supp | dose, data = ToothGrowth,
layout = c(3, 1),
xlab = "Dose", ylab = "Length")
# Strip plot
stripplot(len ~ supp | dose, data = ToothGrowth,
layout = c(3, 1), jitter.data = TRUE,
xlab = "Dose" , ylab = "Length")
xlab = "Dose", ylab = "Length")
densityplot(~ len, data = ToothGrowth,
plot.points = FALSE)
histogram(~ len, data = ToothGrowth,
breaks = 20)
densityplot(~ len, groups = dose, data = ToothGrowth,
plot.points = FALSE, auto.key = TRUE)
Comments
Post a Comment