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.
library(ggplot2)
library(trelliscopejs)
## This package is no longer maintained. Please use the 'trelliscope' package instead (see https://github.com/trelliscope/).
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.3.3
## Warning: package 'tidyr' was built under R version 4.3.3
## Warning: package 'readr' was built under R version 4.3.3
## Warning: package 'purrr' was built under R version 4.3.3
## Warning: package 'dplyr' was built under R version 4.3.3
## Warning: package 'lubridate' was built under R version 4.3.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.1 ✔ stringr 1.5.1
## ✔ lubridate 1.9.4 ✔ tibble 3.2.1
## ✔ purrr 1.0.4 ✔ tidyr 1.3.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
#loading pokemon work space from the data camp resources of our visualizing big data with trelliscope course
#write.csv(pokemon, "pokemon.csv")
pokemon = read.csv("C:/Users/Dominik/Downloads/Assignment/pokemon.csv")
#loading pokemon work space from the data camp resources of our visualizing big data with trelliscope course
xint = mean(pokemon$speed[pokemon$base_experience > 100])
pokemon %>%
select(type_1, speed, base_experience) %>%
filter(base_experience > 100) %>% #filtering for pokemon that are higher experience than 100. Most "baby" pokemon are under 100 experience needed. This increases our average spped by about 10 points.
mutate(typeurl = cog_href( paste0("https://pokemon.fandom.com/wiki/", str_to_title(type_1), "_type"), desc = "Pokemon Fandom Page For Selected Type"
)) %>% #cognostic measure is links to the fandom's wiki page on each type.
ggplot(aes(x = speed)) +
geom_histogram(binwidth = 10) +
geom_vline(xintercept = xint, color = "slateblue", linetype = "twodash") + #adding average spped across all type so we can see how each type fairs against he average.
ylim(c(0,12))+
facet_trelliscope(~ type_1, name = "Pokemon Types",
desc = "Speed by Main Type", nrow = 2, ncol = 3, scales = c("same", "same"),
path = ".",
self_contained = TRUE)
## using data from the first layer
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_bar()`).
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.
##The Data set I am using is from our data camp course, depicting the names, attribute stats, types, and other information pertaining to each Pokemon from generation 1 to generation 6. The variable I chose to analyze in my Trelliscope plots is the speed of each Pokemon. I faceted speed with the main type for each Pokemon. I was curious on whether or not certain types had a naturally higher speed stat than other types. I also included a line in each histogram that shows the mean speed stat across all types of Pokemon, this way I could easily compare how each team does against the majority. I chose a histogram to analyze speed data so I could easily see the spread of stats for each type. A challenge I has was finding which type of graph to use - I attempted a density (line) plot and a box plot as well. The box plot does not facet well with Trelliscope and was very squished/hard to read. The density plot was tough to read/compare the different types. I believe the histogram is a good middle ground, I can see the outlier speed stats that the box plot would show, while being able to visually see how many Pokemon are apart of which bin that the density plot would have shown.
##The Cognostic measure I chose to include in the graph was a link to each type's wiki fandom page. I could not figure out how to always display the links that are clickable, so to see this measure you will have to open the labels tab and click on "typeurl". Another cognostic measure I think would be good to include, would be to create a variable that compares the average defensive stat for a pokemon of that type, to the speed stat shown. This comparison could be via ratio, for example a pokemon with a speed stat of 100 and a defensive stat of 70 would have a .7 defense to speed ratio. The general idea in Pokemon - or really any video game that deals with attributes - is that the higher your defense, the slower you are and vice versa. This cognostic measure could show the readers just how true that idea is, and see if there are certain types who have both a high defense and a high speed. You could overlay this ratio over the histogram graphs in a horizontal line.
##Pokemon with their main type being Dragon, fire, electric, water, or psychic type look to be the fastes from our graphs. Normal types are pretty balanced around our mean speed, while rock, steel, fairy, and ice type Pokemon look to be quite slow. There are only a few pokemon who's main type are flying - but those that are tend to be extremely fast. Physic and Bug types have the Pokemon with the highest speed stat (over 150+).
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