In this assignment we explored Spokane County’s population data. In partciular, we compared data of Native Americans vs Foreign Born people. Then of the Foreign Born people, we compared the data of those who have US citizenship and those who do not.

First we downloaded the data set containing all of the information

library(readxl)
## Warning: package 'readxl' was built under R version 3.4.2
spokaneforeignborn <- read_excel("~/R/win-library/3.4/gudatavizfa17/data/spokaneforeignborn.xlsx")
#View(spokaneforeignborn)

Next we downloaded the data set which had the information on marital status

library(readxl)
spokaneforeignbornmaritalstatus <- read_excel("~/R/win-library/3.4/gudatavizfa17/data/spokaneforeignbornmaritalstatus.xlsx")

We updated the column names so they were more condensed and more readable

spokaneforeignbornmaritalstatus$"MARITAL STATUS"[1]<- "Never"
spokaneforeignbornmaritalstatus$"MARITAL STATUS"[2]<- "Married"
spokaneforeignbornmaritalstatus$"MARITAL STATUS"[3]<- "Seperated"

We downloaded the necessary packages

library(ggplot2)
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyr)
## Warning: package 'tidyr' was built under R version 3.4.2
library(googleVis)
## Warning: package 'googleVis' was built under R version 3.4.2
## Creating a generic function for 'toJSON' from package 'jsonlite' in package 'googleVis'
## 
## Welcome to googleVis version 0.6.2
## 
## Please read Google's Terms of Use
## before you start using the package:
## https://developers.google.com/terms/
## 
## Note, the plot method of googleVis will by default use
## the standard browser to display its output.
## 
## See the googleVis package vignettes for more details,
## or visit http://github.com/mages/googleVis.
## 
## To suppress this message use:
## suppressPackageStartupMessages(library(googleVis))
library(datasets)
library(gudatavizfa17)
library(rcdimple)
## Loading required package: htmlwidgets
## Warning: package 'htmlwidgets' was built under R version 3.4.2
## Loading required package: htmltools
library(taucharts)
library(htmlwidgets)

Next, we rearranged the data set, so we could effectively make a graph

spokaneforeignbornmaritalstatusgather=gather(spokaneforeignbornmaritalstatus, "Origin", "Percentage", c(3,4))
## Warning in if (!is.finite(x)) return(FALSE): the condition has length > 1
## and only the first element will be used

Here we created a dimple chart comparing the marital status of native people vs foreign people

maritalstatusdimple=spokaneforeignbornmaritalstatusgather%>%dimple(
    x = c("MARITAL STATUS", "Origin"), y = "Percentage",
    groups = "Origin", type = "bar",width=600,height=600)%>%
   add_legend()
maritalstatusdimple
saveWidget(maritalstatusdimple,file = "maritalstatusdimple",selfcontained = TRUE)

We rearranged the data again to fit our next graph

spokaneforeignbornmaritalstatusgather2=gather(spokaneforeignbornmaritalstatus, "Origin", "Percentage", c(5,6))
## Warning in if (!is.finite(x)) return(FALSE): the condition has length > 1
## and only the first element will be used
spokaneforeignbornmaritalstatusgather2$marital=as.factor(spokaneforeignbornmaritalstatusgather2$`MARITAL STATUS`)

Here we created a tauchart comparing the marital status of foreign people with US citizenship against foreign people without US citizenship.

Maritalstatustauplot=tauchart(spokaneforeignbornmaritalstatusgather2)%>%tau_bar("Origin","Percentage","marital") %>%
  tau_tooltip(c("Origin", "marital", "Percentage"))%>% tau_legend()
saveWidget(Maritalstatustauplot,file = "Maritalstatustauplot.html",selfcontained = TRUE)
Maritalstatustauplot

Next we downloaded the data set with information on race

library(readxl)
spokaneforeignbornrace <- read_excel("~/R/win-library/3.4/gudatavizfa17/data/spokaneforeignbornrace.xlsx")

We arranged the data so it would be easy to make a graph

spokaneforeignbornracegather=gather(spokaneforeignbornrace, "Origin", "Percentage", c(3,4))
## Warning in if (!is.finite(x)) return(FALSE): the condition has length > 1
## and only the first element will be used

Here we created a dimple chart comparing the race of native people vs foreign people.

racedimple=spokaneforeignbornracegather%>%dimple("Percentage", c("Race", "Origin"),
    groups = "Origin", type = "bar",width=2050,height=600)%>%xAxis(type="addMeasureAxis")%>%yAxis(type="addCategoryAxis")%>%
   add_legend()
racedimple
saveWidget(racedimple,file = "racedimple",selfcontained = TRUE)

We rearranged the data again in order for it to be easy to make a graph

spokaneforeignbornracegather2=gather(spokaneforeignbornrace, "Origin", "Percentage", c(5,6))
## Warning in if (!is.finite(x)) return(FALSE): the condition has length > 1
## and only the first element will be used

Here we created a tau chart compaing the race of foreign people with US citizenship against foreign people without US citizenship

Racetauplot=tauchart(spokaneforeignbornracegather2)%>%tau_bar("Origin","Percentage","Race")%>%
  tau_tooltip(c("Origin", "Race", "Percentage"))%>% tau_legend()
saveWidget(Racetauplot,file = "Racetauplot.html",selfcontained = TRUE)
Racetauplot

Next we downloaded the data set with information on occupations

library(readxl)
spokaneforeignbornoccupations <- read_excel("~/R/win-library/3.4/gudatavizfa17/data/spokaneforeignbornoccupations.xlsx")

Next we arranged the data so it would be easy to graph

spokaneforeignbornoccupationsgather=gather(spokaneforeignbornoccupations,"Origin","percentage",c(3,4))
## Warning in if (!is.finite(x)) return(FALSE): the condition has length > 1
## and only the first element will be used

Here we created a dimple chart comparing the occupations of native people vs foreign people

mydimplebarplot=spokaneforeignbornoccupationsgather%>%dimple("percentage",c("Occupation","Origin"),
    groups = "Origin", type = "bar",width=700,height=700)%>%xAxis(type="addMeasureAxis")%>%yAxis(type="addCategoryAxis")%>%
   add_legend()%>% set_bounds(y=50,x=325,width=250,height=300)
saveWidget(mydimplebarplot,file = "Occupationdimple.html",selfcontained = TRUE)
mydimplebarplot

We rearranged the data again to more easily make a graph

spokaneforeignbornoccupationsgather2=gather(spokaneforeignbornoccupations,"Origin","percentage",c(5,6))
## Warning in if (!is.finite(x)) return(FALSE): the condition has length > 1
## and only the first element will be used

Here we created a tau chart comparing the occupations of foreign people with US citizenship against foreign people without US citizenship

Occupationtauplot=tauchart(spokaneforeignbornoccupationsgather2)%>%tau_bar("Origin","percentage","Occupation")%>%
  tau_tooltip(c("Origin", "Occupation", "percentage"))%>% tau_legend()
saveWidget(Occupationtauplot,file = "Occupationtauplot.html",selfcontained = TRUE)
Occupationtauplot

Next we downloaded the dataset with information on gender

library(readxl)
spokaneforeignborngender <- read_excel("~/R/win-library/3.4/gudatavizfa17/data/spokaneforeignborngender.xlsx")

Here we created a tau chart comparing the gender of native people vs foreign people

spokaneforeignborngender$Identity=as.factor(spokaneforeignborngender$Identity)
spokaneforeignborngender$Gender=as.factor(spokaneforeignborngender$Gender)
genderplot=tauchart(spokaneforeignborngender)%>%tau_bar("Identity","Percent","Gender")%>%
  tau_tooltip(c("Identity", "Gender", "Percent"))%>% tau_legend()
saveWidget(genderplot,file = "genderplot.html",selfcontained = TRUE)
genderplot
library(readxl)
spokaneforeignborngender2 <- read_excel("~/R/win-library/3.4/gudatavizfa17/data/spokaneforeignborngender2.xlsx")

Here we created a dimple chart comparing the gender of foreign people with US citizenship vs foreign people without US citizenship

Genderdimple=spokaneforeignborngender2%>%dimple(
    x = c("Gender", "Identity"), y = "Percent",
    groups = "Identity", type = "bar",width=600,height=600)%>%
   add_legend()
Genderdimple
saveWidget(Genderdimple,file = "Genderdimple",selfcontained = TRUE)

Next we downloaded the data set with information on age

library(readxl)
spokaneforeignbornage1 <- read_excel("~/R/win-library/3.4/gudatavizfa17/data/spokaneforeignbornage1.xlsx")

Here is a dimple chart comparing the age of native people vs foreign people

Agedimple=spokaneforeignbornage1%>%dimple(
    x = c("Age", "Identity"), y = "Amount",
    groups = "Identity", type = "bar",width=600,height=600)%>%
   add_legend()
Agedimple
saveWidget(Agedimple,file = "Agedimple",selfcontained = TRUE)
library(readxl)
spokaneforeignbornage2 <- read_excel("~/R/win-library/3.4/gudatavizfa17/data/spokaneforeignbornage2.xlsx")

Here is a tau chart comparing the age of foreign people with US citizenship against foreign people without US citizenship

Agetauplot=tauchart(spokaneforeignbornage2)%>%tau_bar("Identity","Amount","Age")%>%
  tau_tooltip(c("Identity", "Age", "Amount"))%>% tau_legend()
saveWidget(Agetauplot,file = "Agetauplot.html",selfcontained = TRUE)
Agetauplot