#Sample Solution
---
title: "Interquartile Range"
output: html_notebook
---
```{r message=FALSE, warning=FALSE}
# load libraries
library(ggplot2)
```
```{r}
# load song data
load("songs.Rda")
```
```{r}
# find maximum and minimum song lengths
maximum <- max(songs)
minimum <- min(songs)
```
```{r}
# create variable song_range here:
song_range <- maximum - minimum
```
```{r message=FALSE, echo=FALSE}
# plot histogram
hist <- qplot(songs,
geom="histogram",
main = 'Histogram of Song Lengths',
xlab = 'Song Length (Seconds)',
ylab = 'Count',
fill=I("blue"),
col=I("red"),
alpha=I(.2))
hist
```
```{r}
# ignore the code below here:
tryCatch(print(paste("The range of the dataset is",song_range)), error=function(e) {print("You haven't defined the variable song_range yet")})
```
No comments:
Post a Comment