---
title: "R_3d_plots_intro"
author: "Matthew McGowan"
date: "April 29, 2020"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

# Load dependencies
car_test <- require("car")
rgl_test <- require("rgl")
if (!car_test)
{
  install.packages("car", repos='http://cran.us.r-project.org')
  library(car)
  install.packages("rgl", repos='http://cran.us.r-project.org')
  library(rgl)
}
if (!rgl_test)
{
  install.packages("rgl", repos='http://cran.us.r-project.org')
  library(rgl)
}

# Load the data
data(iris)

# Extract plot data
sep.l <- iris$Sepal.Length
sep.w <- iris$Sepal.Width
pet.l <- iris$Petal.Length
```

## Plot 1: A Basic 3D plot with defaults

Working through the online tutorial on RGL [HERE](http://www.sthda.com/english/wiki/amazing-interactive-3d-scatter-plots-r-software-and-data-visualization)

The first plot is based off the R Iris dataset. It is just a basic 3D scatter plot of sepal length, sepal width, and petal length

```{r basic_3D_plot, echo = F}
# 3D plot with the regression plane
basic_3d_plot <- scatter3d(x = sep.l, y = pet.l, z = sep.w)
rglwidget(elementId = "basic_3d_plot") # This line is what causes Knitr to include the interactive plot in your markdown
```

## Plot 2: Changing the point colors

Continue on with the tutorial....

```{r changing_point_colors, echo=FALSE}
# YOUR CODE FOR THE NEXT SECTION GOES HERE
```