-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiamonds.Rmd
More file actions
89 lines (58 loc) · 1.71 KB
/
Copy pathdiamonds.Rmd
File metadata and controls
89 lines (58 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
title: "Diamonds"
author: "Rita Raher"
date: "4/13/2020"
output: rmarkdown::github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
if (!require("dplyr")) install.packages("dplyr"); library(dplyr)
if (!require("ggplot2")) install.packages("ggplot2"); library(ggplot2)
if (!require("GGally")) install.packages("GGally"); library(GGally)
```
## R Markdown
For this analysis, I will use the diamonds dataset freely available in R.
https://ggplot2.tidyverse.org/reference/diamonds.html
Libraries:
- ggplot
- dplyr
- GGally
### Data Exploration
```{r diamonds head}
head(diamonds)
```
```{r diamonds summary}
summary(diamonds)
```
## Including Plots
```{r diamond cut, echo=FALSE}
unique(diamonds$cut)
```
```{r diamond plot, echo=FALSE}
diamonds %>%
ggplot(aes(carat, price, color =cut)) +
geom_point() +
scale_y_log10()
```
```{r diamond plot facet, echo=FALSE}
diamonds %>%
ggplot(aes(carat, price, color =cut)) +
geom_point() +
scale_y_log10() +
facet_wrap(~cut) +
ggtitle("Diamond carat by price ")
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
```{r diamond correlation, echo=FALSE}
ggcorr(diamonds, method = c("everything", "pearson"))
```
Turning levels 'cut', 'color', 'clarity' in numeric values to see if there is a correlation
```{r diamond levels_to_numeric , echo=FALSE}
diamonds$cut <- as.numeric(diamonds$cut)
diamonds$color <- as.numeric(diamonds$color)
diamonds$clarity <- as.numeric(diamonds$clarity)
#ggpairs(diamonds, columns = 2:4, ggplot2::aes(colour=))
```
```{r diamond correlation_upgrade, echo=FALSE}
ggcorr(diamonds, method = c("everything", "pearson"))
```