Dear Friends, I’ve decided to start up a series of posts called ‘#DailyR.’ My goal is to provide some example code to perform common tasks using R. I also want to spend a few days a week on slightly more complicated tasks, and perhaps throw in a little python every once in a while. If you like the content, please like and share! Until next time!
- Use theme_set to try various pre-set themes
- Use options to turn off scientific notation
- Use geom_point for a simple scatter plot
Create a Scatter Plot
library(ggplot2) # load package library(cowplot) theme_set(theme_cowplot()) # pre-set theme data("iris") # load data set options(scipen=999) # turns off scientific notation gg <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point(aes(col = Species, size = Petal.Length)) + xlim(c(min(iris$Sepal.Length), max(iris$Sepal.Length))) + ylim(c(min(iris$Sepal.Width), max(iris$Sepal.Width))) + labs(subtitle = "Sepal Length vs. Sepal Width", y = "Sepal Width", x = "Sepal Length", title = "Scatterplot", caption = "Source: iris dataset") plot(gg)