This week's assignment was to make visualizations in three different ways in R. 

I chose a humorous Beenie baby dataset to work with from the list chosen that is based around the age of the Beenie and its current price.  

Dataset can be located here: https://vincentarelbundock.github.io/Rdatasets/datasets.html

My first 2 plots were simple plots using built in R commands:

plot(beanie$age, beanie$value,

     main = "Beanie Value vs Age",

     xlab = "Age",

     ylab = "Value")

hist(beanie$value,

     main = "Distribution of Beanie Values",

     xlab = "Value")



Next I was told to make a plot using "lattice" 

xyplot(value ~ age, data = beanie,

       main = "Value vs Age",

       xlab = "Age",

       ylab = "Value",

       col = "blue")


bwplot(age ~ value, data = beanie,

       main = "Value by Age Group")




Finally I had to use ggplot 2 to plot one final visualization

ggplot(beanie, aes(x = age, y = value, color = age)) +

  geom_point(size = 3) +

  geom_smooth(method = "lm", se = FALSE) +

  labs(title = "Beanie Value vs Age",

       x = "Age",

       y = "Value",

       color = "Age Group") +

  theme_minimal()



The syntax between each only differs slightly but with each of lattice and ggplot you can see how much more detailed and clear the images are. As I have worked extensively with ggplot 2 and minimally with lattice I did have to look up how to actually use the commands but it worked itself out easily

Comments

Popular posts from this blog

Assignment #10: Building Your Own R Package

Module # 7 R Object: S3 vs. S4 assignment

Week 3