#Sample Solution
---
title: "Quantiles"
output: html_notebook
---
```{r}
# load song data
load("songs.Rda")
```
```{r}
# define quartiles and deciles here:
quartiles <- quantile(songs, c(0.25, 0.5, 0.75))
decile_array <- c()
for(k in 1:9){
decile_array[k]<-k/10
}
decile_array
deciles <- quantile(songs, decile_array)
deciles
```
```{r}
# define tenth here:
tenth <- 3
```
```{r}
# ignore the code below here:
tryCatch(print(paste(c("The quartiles are",quartiles,collapse=" "))), error=function(e) {print("You haven't defined quartiles.")})
tryCatch(print(paste(c("The deciles are",deciles,collapse=" "))), error=function(e) {print("You haven't defined deciles.")})
```
No comments:
Post a Comment