Published on Jan 09,2015
Email Post

3D Graphs in R Commander

3D Graphs in R Commander have the potential to amaze people. They transform the data from a tedious table format to an appealing, easy to understand and simple to view plot. This property to be able to view data as a 3D object, to be able to toss and turn it to have multiple viewing angles, makes a 3D graph very useful and popular with Analysts.

R Commander allows us to use the R Console functionality with a Graphical User Interface. A 3D Graph can be easily plotted using R Commander without any lines of code. This, in itself, says a lot about the efficiency of R Commander as a Statistical Interface for R.

Below is an easy method to create a 3D graphs in R commander:

Step 1: Installing and Uploading Rcmdr

  • R Commander can be installed from the R Console using the command:  install.packages(“Rcmdr”)
  • Once installed, like all other packages in R, R Commander needs to be loaded using the command: library(Rcmdr)

Installing and uploading Rcmdr

Step 2: Creating an Active Data Set

Active Dataset is the term used for the set of values that is to be currently analyzed in the Rcmdr.

  • To create a 3d Graph, you need to load your dataset in the “Data Editor Window”, some datasets present in the R package by default like cars, diamonds, etc can also be made use of.

We are using a simple dataset and manually entering values in the data editor window, which include Height, Weight and Age columns.

Data value

The Dataset can also be loaded into the data editor by importing a file. This file can be a text file, excel sheet, STATA dataset, SAS dataset, etc.

Step 3: Numerical Summaries

When you have your active dataset ready, you need to set the Numerical Summaries which include:

  • Mean
  • Standard Deviation
  • Interquantile Range
  • Coefficient of Variation
  • Skewness
  • Kurtosis

Either or all of them can be selected, based on the type of output you want.

e.g. I want to calculate all the above functions for ‘Age’ of the persons.

Numerical summaries

The variable selected can be summarized by any of the above mentioned functions, by checking the box and the result will be displayed in the output window of the Rcmdr.

The following snapshot gives the output of the mean, SD, Coefficient of variation, etc. computed on the ‘Age’ input.


Step 4: Configuring the 3D Scatterplot

  • You can plot the values in Rcmdr in 3D using the 3D Scatterplot. A scatterplot requires a Response variable and a pair of Explanatory variables.

Response variable is the variable on which your explanatory variables depend. It is like an occurrence and explanatory variables are the reasons for that occurrence.

Here we are taking ‘Age’ as a Response variable and ‘Height’ and ‘Weight’ as the explanatory variables.

Response Variable

Rcmdr gives you the flexibility in plotting by providing options to view the axis scales, grid lines, residuals and regression, etc.

If I want to plot a simple 3D Graph, I would select just the Axis Scales and Grid lines and the graph would look like this:

3D Graph in R Commander

Here, you can see Age, Height and Weight being on the three axis, and the yellow dots are the points of plot of these values. Age being the Response variable, height and weight are plotted with respect to it, as is clear from the 3D Scatterplot.

Moreover if you want to manipulate the output furthermore, you can do that by applying the functions of:

              Plot 1 : Linear Least Squares

Linear Least Squares

             Plot 2 : Quadratic Least Squares

Linear Least Squares

             Plot 3 : Smooth Regression

Smooth Regression

             Plot 4 : Concentrated Ellipsoid

Concentrated Ellipsoid

The above mentioned plots are some of the plots that R commander can create along with some other plots like Boxplot, Histogram, Strip chart, Index Plot, Stem and Leaf display, etc. which will be discussed in the next blog.

Got a question for us? Please mention them in the comments section and we will get back to you.

Related Posts:

Business Analytics With R Training

R Tutorial for Analytics and Data Science Jobs

About Author
Published on Jan 09,2015

Share on

Browse Categories

1 Comment