Last active
March 6, 2017 22:12
-
-
Save ryanburge/1bce7a48995cbf82995668c5c3e18d2c to your computer and use it in GitHub Desktop.
Here's the RMarkdown Syntax for 3/6/2017
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Here is a Title" | |
author: "Ryan Burge" | |
date: "March 6, 2017" | |
output: html_document | |
--- | |
```{r message=FALSE, warning=FALSE} | |
simon <- read.csv(url("http://goo.gl/exQA14")) | |
library(dplyr) | |
library(car) | |
library(ggplot2) | |
library(descr) | |
``` | |
1. Create a variable that gives the actual age of each respondent. Make sure to deal with those who didn't respond. | |
```{r message=FALSE, warning=FALSE} | |
simon$age <- 2017 - simon$birth_yr | |
simon$age <- Recode(simon$age, "117=0") | |
table(simon$age) | |
hist(simon$age) | |
``` | |
2. Using filter, create a dataset of just cell users and another dataset of just landline users | |
```{r message=FALSE, warning=FALSE} | |
cell <- filter(simon, type ==2) | |
land <- filter(simon, type ==1) | |
``` | |
3. Use ggplot to compare the age distribution of the two subsamples. | |
```{r message=FALSE, warning=FALSE} | |
ggplot(cell, aes(age)) + geom_bar(fill = "red", colour = "black") | |
ggplot(land, aes(age)) + geom_bar(fill = "red", colour = "black") | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment