Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hw3-TinLizzie58 (Elizabeth Mulvey) #145

Open
wants to merge 7 commits into
base: hw3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions 2014__10_23_Mulvey_Elizabeth .R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
setwd("/Users/elizabethmulvey/qmssviz/hw3")

load('WV5_Data_rdata_v_2014_04_28_2.rdata')
load('WV6_Data_rdata_v_2014_06_04.rdata')
d <- WV5_Data_spss_v_2014_04_28
d2 <- WV6_Data_spss_v_2014_06_04

subsetd<-subset(d, V2A== 840 | V2A== 484)

require(ggplot2)


bar1 <- ggplot(subsetd, aes(x=V68, xlab= "Countries")) +
geom_histogram(binwidth=1, color="white", fill="blue") +
coord_cartesian(xlim=c(0,10)) +
xlab("Countries (Mexico and the U.S.)") + ggtitle("Financial Satisfaction on a Scale from 0 to 10")
bar1
bar1 + facet_grid(. ~ V2)


density1 <- ggplot(data = subsetd, aes(x = V68, col=V2)) + geom_density(aes(group = V2, color=V2)) + ggtitle("Financial Satisfaction 2005-2009: Mexico (dark blue) v. US (light blue)") + xlab("0= Dissatisfied, 10=Satisfied")
density1



subsetd2<-subset(d2, V2A== 840 | V2A== 484)


bar2 <- ggplot(subsetd2, aes(x=V59, xlab= "Countries")) +
geom_bar(binwidth=1, color="white", fill="green") +
coord_cartesian(xlim=c(0,10)) +
xlab("Countries (Mexico and the U.S.)") + ggtitle("Financial Satisfaction: 2010-2014)")
bar2
bar2 + facet_grid(. ~ V2)

density2 <- ggplot(data = subsetd2, aes(x = V59, col=V2)) + geom_density(aes(group = V2, color=V2)) + ggtitle("Financial Satisfaction 2010-2014: Mexico (dark blue) v. US (light blue)") + xlab("0= Dissatisfied, 10=Satisfied")
density2


87 changes: 87 additions & 0 deletions Lab1/Mulvey_Lab2.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
title: "Mulvey_Lab2"
output: html_document
---

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r}

setwd("~/Desktop/QMSS_Semester_1/Data Viz")
getwd()
setwd("~/Desktop/QMSS_Semester_1/Data Viz")
d <- read.csv('lgas.csv')
str(d)
df <- data.frame()
nd <- read.csv('sample_health_facilities.csv')
nd


newdata <- subset(nd, zone == "South-South" | zone == "Southwest" | zone == "Southeast")
newdata
newd <- c("lga_id", "pop_2006")
newd
newdata
newd <- subset(d, select=c(lga_id, pop_2006, area_sq_km, pop_density_2006))
newd

south <- merge(newdata, newd, by = "lga_id")

merge(newdata, newd, by = "lga_id", all=FALSE)

south
south$Dperarea <-south$area_sq_km / south$num_doctors_fulltime
south$Dpercapita <-south$pop_2006 / south$num_doctors_fulltime
south$Nperarea <- south$area_sq_km / south$num_nurses_fulltime
south$Npercapita <-south$pop_2006 / south$num_nurses_fulltime
south

south$Dperarea <- as.character(south$Dperarea)
south$Dperarea[south$Dperarea == "Inf"] <- "0"

south$Dpercapita <- as.character(south$Dpercapita)
south$Dpercapita[south$Dpercapita == "Inf"] <- "0"

south$Nperarea <- as.character(south$Nperarea)
south$Nperarea[south$Nperarea == "Inf"] <- "0"

south$Npercapita <- as.character(south$Npercapita)
south$Npercapita[south$Npercapita == "Inf"] <- "0"

south
south$Dperarea <- as.numeric(south$Dperarea)
south$Dpercapita <- as.numeric(south$Dpercapita)
south$Nperarea <- as.numeric(south$Nperarea)
south$Npercapita <- as.numeric(south$Npercapita)
south

#south <- transform(south, Dperarea = area_sq_km/ num_doctors_fulltime)

#aggregate( cbind( num_nurses_fulltime , num_doctors_fulltime ) ~ state , data = south , FUN=sum )


summing <- data.frame(south$state,south$num_doctors_fulltime,south$num_nurses_fulltime, south$pop_2006, south$area_sq_km, south$pop_density_2006, south$Dperarea, south$Dpercapita, south$Nperarea, south$Npercapita)
summing



#summary(summing)
#sum(summing$Delta$south.num_nurses_fulltime)
#aggregate(x = summing, list(state = south.state), FUN = "sum")
#aggregate(south.num_doctors_fulltime ~ south.state, data = summing, sum)


#install.packages("plyr")
#install.packages("reshape2")
library(plyr)
library(reshape2)

summing2 <- ddply(summing, .(south.state), numcolwise(sum), na.rm=TRUE)
summing2

summing2[order(summing2$south.pop_2006, decreasing=TRUE), ]

```

1,973 changes: 1,973 additions & 0 deletions Lab1/Mulvey_Lab2.html

Large diffs are not rendered by default.

Loading