100 lines
1.6 KiB
Plaintext
100 lines
1.6 KiB
Plaintext
---
|
|
title: "Rozmiary diamentów"
|
|
date: 2016-08-25
|
|
output: html_document
|
|
---
|
|
|
|
```{r setup, include = FALSE}
|
|
|
|
knitr::opts_chunk$set(echo = FALSE)
|
|
|
|
library(ggplot2)
|
|
library(dplyr)
|
|
library(tidyverse)
|
|
|
|
smaller <- diamonds %>%
|
|
filter(carat <= 2.5)
|
|
```
|
|
|
|
Mamy dane o `r nrow(diamonds)` diamentach. Tylko
|
|
`r nrow(diamonds) - nrow(smaller)` diamentów jest większych niż 2,5 karata.
|
|
Poniżej przedstawiony jest rozkład pozostałych:
|
|
|
|
```{r, echo = FALSE}
|
|
smaller %>%
|
|
ggplot(aes(carat)) +
|
|
geom_freqpoly(binwidth = 0.01)
|
|
```
|
|
|
|
# Wielkość diamentów w zależności od szlifu, koloru i przejrzystości.
|
|
|
|
## Wielkość vs. Szlif
|
|
|
|
```{r}
|
|
diamonds %>%
|
|
ggplot(aes(x=cut, y=carat)) +
|
|
geom_boxplot()
|
|
```
|
|
|
|
## Wielkość vs. Kolor
|
|
|
|
```{r}
|
|
diamonds %>%
|
|
ggplot(aes(x=color, y=carat)) +
|
|
geom_boxplot()
|
|
```
|
|
|
|
## Wielkość vs. Przejrzystość
|
|
|
|
```{r}
|
|
diamonds %>%
|
|
ggplot(aes(x=clarity, y=carat)) +
|
|
geom_boxplot()
|
|
```
|
|
|
|
## TOP 20 diamnetów pod względem wielkości
|
|
|
|
```{r}
|
|
diamonds %>%
|
|
top_n(20, wt=carat) %>%
|
|
knitr::kable()
|
|
```
|
|
|
|
|
|
```{r}
|
|
comma <- function(x) format(x, digits = 2, big.mark = ",")
|
|
|
|
|
|
diamonds %>%
|
|
group_by(carat > 2.5) %>%
|
|
summarise(count=n()) %>%
|
|
pivot_wider(names_from=`carat > 2.5`, values_from=count) %>%
|
|
mutate(bigger_than_2.5 = as.numeric(`TRUE`)/as.numeric(sum(`TRUE`+`FALSE`))) %>%
|
|
select(bigger_than_2.5) -> bigger_than_2.5
|
|
|
|
|
|
percent <- bigger_than_2.5$bigger_than_2.5*100
|
|
```
|
|
|
|
|
|
Odsetek diamentów większych niż 2.5 karata wynosi `r comma(percent)`%.
|
|
|
|
|
|
```{r a, cache=TRUE}
|
|
lubridate::now()
|
|
```
|
|
|
|
```{r b, cache=TRUE}
|
|
lubridate::now()
|
|
```
|
|
|
|
```{r c, cache=TRUE}
|
|
lubridate::now()
|
|
```
|
|
|
|
```{r d, cache=TRUE}
|
|
lubridate::now()
|
|
```
|
|
|
|
|