wk9
assas
2023-03-08
datai = read.csv("StressAnxiety.csv")
datai = datai[,-1]
# create an empty plot with the correct axis
limits
plot(datai$stress, datai$anxiety, xlab="stress", ylab="anxiety")
# add the points to the plot
points(datai$stress, datai$anxiety, pch=16, col="blue")
# add a title
title("Stress vs Anxiety")
#2
library(lattice)
xyplot(datai$anxiety ~ datai$stress, data = datai, type = c("h"))
#3
library(ggplot2)
ggplot(datai, aes(x = stress, y = anxiety, group = stress)) +
geom_boxplot()
#while R's built-in plotting
functions can be useful for basic plotting needs, lattice and ggplot2 offer
much more powerful and flexible visualization capabilities that enable users to
create more complex and customized plots. However, there is a learning curve
for using these packages, and they may not be the best choice for very simple
plots or when speed is a priority.
Comments
Post a Comment