For a data set of your choosing, make a faceted plot using the trelliscopejs package. You may make any type of plot; scatter plot, histogram, etc. but, as mentioned in the discussion below, you must explain why you chose this plot and what you are investigating about the variable you are graphing.
The trelliscope plot must include one cognostic measure of your own. Include a description of what it is and what information this measure gives.
Description 2-3 paragraphs.
Describe the data set. Explain the variable you are graphing in your plots and the reason you are investigating with it. Discuss the reason/motivation you chose the variable to facet on, and what insight or trend you are attempting to investigate. Discuss any challenges you had in making the graphs and how you dealt with these challenges. Name at least one cognostic measure (this can include the cognostic you created or be different) the reader could investigate, and explain any insight they might gain from it.
knit the file to an html document
publish this to an RPubs page.
grading: trelliscope plot[25 points], discussion[25 points]
Note: you can add a url directly to the text and it will be active in the html (and word document if you knit to that)
Example: https://www.google.com
If you want to be fancy and make your url active text, you can do this
The data set used in this code is the famous “diamonds” dataset from the ggplot2 package. The dataset consists of the prices and attributes of approximately 54,000 round-cut diamonds, including carat weight, cut, color, and clarity.
The variable being graphed in this code is “carat,” which represents the weight of each diamond in carats. The code filters the data to only show diamonds with prices less than $1000 and then plots a histogram of the carat weight. The reason for investigating the relationship between price and carat weight is to see if there is a significant difference in the size of diamonds available at different price points.
The reason for facetting the graph by price is to examine if there is a noticeable trend in the distribution of carat weights at different price points. The insight that can be gained from this graph is whether there is a correlation between the price of diamonds and the size of diamonds available at that price point. Additionally, the facet_trelliscope function is used to create an interactive visualization that allows the user to explore the data more closely by filtering the diamonds based on price.
#Loading Libraries
library(tidyverse)
## Warning: package 'tibble' was built under R version 4.2.3
## Warning: package 'dplyr' was built under R version 4.2.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.1 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(trelliscopejs)
## Warning: package 'trelliscopejs' was built under R version 4.2.3
library(ggplot2)
#Loading diamonds datas et
data <- diamonds
#filtering to diamond less than $1000 to see the difference in diamond carat size
data %>%
filter(price < 1000) %>%
ggplot(aes(x=carat)) +
geom_histogram(binwidth = 0.1) +
facet_trelliscope(~ price,
name = "price",
desc = "price",
nrow = 2,
ncol = 2,
width = 800,
height = 600,
path = ".",
self_contained = TRUE)
## using data from the first layer