Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 90
Kernel: R (SageMath)

CDS-102: Lab 6 Workbook

Name: Nathaniel Sposit

March 2, 2017

# Run this code to install the GGally package (you only need to run this once) install.packages("GGally", lib = "~/Rlibs")
The downloaded source packages are in ‘/tmp/Rtmpqyi3HM/downloaded_packages’
# Run this code block to load the Tidyverse package .libPaths(new = "~/Rlibs") library(tidyverse) library("GGally") # This converts the iris data.frame to a tibble iris <- as_tibble(iris)
Loading tidyverse: ggplot2 Loading tidyverse: tibble Loading tidyverse: tidyr Loading tidyverse: readr Loading tidyverse: purrr Loading tidyverse: dplyr Conflicts with tidy packages --------------------------------------------------- filter(): dplyr, stats lag(): dplyr, stats Attaching package: ‘GGally’ The following object is masked from ‘package:dplyr’: nasa
print(iris)
# A tibble: 150 × 5 Sepal.Length Sepal.Width Petal.Length Petal.Width Species <dbl> <dbl> <dbl> <dbl> <fctr> 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 4 4.6 3.1 1.5 0.2 setosa 5 5.0 3.6 1.4 0.2 setosa 6 5.4 3.9 1.7 0.4 setosa 7 4.6 3.4 1.4 0.3 setosa 8 5.0 3.4 1.5 0.2 setosa 9 4.4 2.9 1.4 0.2 setosa 10 4.9 3.1 1.5 0.1 setosa # ... with 140 more rows
petal.width.length <- ggplot(data = iris) + geom_point(mapping = aes(Petal.Length, Petal.Width)) ggsave("PetalWidthLength.png", plot = petal.width.length, device = "png", scale = 1, width = 5, height = 4) print(petal.width.length)
Image in a Jupyter notebook
sepal.width.length <- ggplot(data = iris) + geom_point(mapping = aes(Sepal.Length, Sepal.Width)) ggsave("SepalWidthLength.png", plot = sepal.width.length, device = "png", scale = 1, width = 5, height = 4) print(sepal.width.length)
Image in a Jupyter notebook
petal.width.length.species <- ggplot(data = iris) + geom_point(mapping = aes(Petal.Length, Petal.Width, color = Species)) ggsave("PetalWidthLengthSpecies.png", plot = petal.width.length.species, device = "png", scale = 1, width = 5, height = 4) print(petal.width.length.species)
Image in a Jupyter notebook
sepal.width.length.species <- ggplot(data = iris) + geom_point(mapping = aes(Sepal.Length, Sepal.Width, color = Species)) ggsave("SepalWidthLengthSpecies.png", plot = sepal.width.length.species, device = "png", scale = 1, width = 5, height = 4) print(sepal.width.length.species)
Image in a Jupyter notebook
scatter.matrix <- ggpairs(data = iris, columns=1:4, upper = list(continuous = "points"), diag = NULL, mapping = aes(color=Species), legend = 3) + theme(legend.position = "right") ggsave("ScatterplotMatrix.png", plot = scatter.matrix, device = "png", scale = 1, width = 5, height = 4) print(scatter.matrix)
Image in a Jupyter notebook
sepal.histo <- ggplot(iris, aes(Sepal.Length)) + geom_histogram(binwidth=5) + facet_wrap(~Species) ggsave("SepalHisto.png", plot = sepal.histo, device = "png", scale = 1, width = 5, height = 4) print(sepal.histo)
Image in a Jupyter notebook
sepal.density <- ggplot(iris, aes(Sepal.Length)) + geom_density(kernel = "gaussian") + facet_wrap(~Species) ggsave("SepalDensity.png", plot = sepal.density, device = "png", scale = 1, width = 5, height = 4) print(sepal.density)
Image in a Jupyter notebook