# import packages
library(readxl)
library(dplyr)
library(tidyr)
library(ggplot2)
library(trelliscopejs)
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.
# load in phone sales data
df <- read.csv("sales.csv")
# view structure
str(df)
## 'data.frame': 3114 obs. of 11 variables:
## $ Brands : chr "SAMSUNG" "Nokia" "realme" "Infinix" ...
## $ Models : chr "GALAXY M31S" "3.2" "C2" "Note 5" ...
## $ Colors : chr "Mirage Black" "Steel" "Diamond Black" "Ice Blue" ...
## $ Memory : chr "8 GB" "2 GB" "2 GB" "4 GB" ...
## $ Storage : chr "128 GB" "16 GB" "" "64 GB" ...
## $ Camera : chr "Yes" "Yes" "Yes" "Yes" ...
## $ Rating : num 4.3 3.8 4.4 4.2 4.6 4 NA 4.6 4.2 4.3 ...
## $ Selling.Price : int 19330 10199 6999 12999 49900 2199 99900 42999 20400 21736 ...
## $ Original.Price: int 20999 10199 7999 12999 49900 2199 99900 47900 20400 22999 ...
## $ Mobile : chr "SAMSUNG GALAXY M31S" "Nokia 3.2" "realme C2" "Infinix Note 5" ...
## $ Discount : int 1669 0 1000 0 0 0 0 4901 0 1263 ...
# format prices into correct dollar amounts
df$Selling.Price <- df$Selling.Price / 100
df$Original.Price <- df$Original.Price / 100
df$Discount <- df$Discount / 100
# add a cognostic for the discount percent
df$Discount.Percent <- cog(round(df$Discount / df$Original.Price, 2), desc = "Discount Percent")
# trelliscope plot
ggplot(df, aes(x = Selling.Price, y = Rating)) +
geom_point(color = "lightseagreen") +
labs(x = "Selling Price", y = "Rating") +
geom_smooth(method = "lm", color = "hotpink4", se = FALSE) +
facet_trelliscope(~ Brands,
nrow = 2, ncol = 3,
name = "Phone Rating vs Price By Brand",
desc = "Examining the correlation between price and customer satisfaction",
scales = "sliced",
path = ".",
self_contained = TRUE)
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