Join Barton Poulson for an in-depth discussion in this video Creating 3D scatterplots, part of Learning R.
In the last movie, we looked at how you could use scatterplot matrices to show the associations between several quantitative variables simultaneously by creating a 2D matrix of scatterplots. In this movie, I want to look at an interesting variation where you actually use a 3D scatterplot that rotates in space with the mouse. To do this, I'm going to use the data set google_correlate that I've used for the other ones. I'm going to load it on line 6. Just get a list of names with line 7.
Then there's actually several ways to do 3D scatterplots in R. I'm going to be using the package rgl. I've now downloaded it, and installed it. Now I'm going to open it to run. Then what I'm going to do is just run this one set of code. plot3d is the function, and then you need to list the x, y, and z variables. So, I've got them all as data_viz from the Google data set degree from the Google data set, and Facebook. Those are relative interest as search terms.
Then I'm also adding labels for the x, y, and z axis. I'm going to color the dots in the scatterplot red, and make them three pixels. If I highlight all of that code, and run it -- this plot is a little different, because it doesn't open in the bottom right window, and instead, it opens a new window. I'm going to come down here and click. I can make that larger. What I can do now is click on the mouse, and drive this one around to see the association in three dimensions.
Now, this is a nice heuristic thing, although it usually only works while it's moving, because as soon as you stop moving, it collapses, and it's hard to read what it is. But it does give interesting possibilities for looking at the associations between three variables, so we can try to find the strongest association. We've got a data point way up here in the corner. Anyhow, while it's interesting for exploring, it's hard to report these, especially in a printed 2D format, but a 3D scatterplot, an interactive spinning one, can be a potentially informative, and certainly an engaging way of exploring the relationship between several quantitative variables.
The course continues with examples on how to create charts and plots, check statistical assumptions and the reliability of your data, look for data outliers, and use other data analysis tools. Finally, learn how to get charts and tables out of R and share your results with presentations and web pages.
- What is R?
- Installing R
- Creating bar character for categorical variables
- Building histograms
- Calculating frequencies and descriptives
- Computing new variables
- Creating scatterplots
- Comparing means