Data Visualization in rrr

The Philosophy of Graphics in rrr

The graphical display of data should be intuitive enough that any viewer of the display unfamiliar with the data, even unfamiliar with statistical analysis generally, should be able to see clear patterns, if in fact clear patterns exist in the data. This, the author believes, is especially true for multivariate data, where due to the higher dimensionality of the data, the potential for visualization to overwhelm is high.

library(dplyr)

### LOAD DATA

### TOBACCO DATA SET
data(tobacco)

tobacco_x <- tobacco %>%
    select(starts_with("X"))

tobacco_y <- tobacco %>% 
    select(starts_with("Y"))

### PENDIGITS DATA SET
data(pendigits)
digits <- as_data_frame(pendigits)

digits_class <- digits %>% select(V35)
digits_features <- digits %>% select(-V35, -V36)

### COMBO-17 GALAXY DATA SET
data(COMBO17)
galaxy <- as_data_frame(COMBO17) %>%
       select(-starts_with("e."), -Nr, -UFS:-IFD) %>%
       na.omit()

### IRIS DATA SET
data(iris)
iris <- as_data_frame(iris)

iris_features <- iris %>%
    select(-Species)

iris_class <- iris %>%
    select(Species)

### COMBO-17 DATA SET
data(COMBO17)
galaxy <- as_data_frame(COMBO17) %>%
       select(-starts_with("e."), -Nr, -UFS:-IFD) %>%
       na.omit()

galaxy_x <- galaxy %>%
    select(-Rmag:-chi2red)

galaxy_y <- galaxy %>%
    select(Rmag:chi2red)

Rank Trace Plots

rank_trace() can draw rank trace plots for reduced-rank regression, principal components analysis and canonical variate analysis by setting type = "identity" (the default), type = "pca", or type = "cva", respectively.

rank_trace(tobacco_x, tobacco_y)
rank_trace(digits_features, digits_features, type = "pca")
rank_trace(galaxy_x, galaxy_y, type = "cva")

Rank trace plots can be made interactive with the argument interactive = TRUE.

rank_trace(tobacco_x, tobacco_y, interactive = TRUE)
rank_trace(digits_features, digits_features, type = "pca", interactive = TRUE)
rank_trace(galaxy_x, galaxy_y, type = "cva", interactive = TRUE)

Residual Plots

residuals(tobacco_x, tobacco_y, rank = 1)
residuals(galaxy_x, galaxy_y, type = "cva")

Pairwise Plots

Pairwise plots can be created for PCA, CVA, LDA, by setting type = "pca", type = "cva", and type = "lda", respectively.

pairwise_plot(digits_features, digits_class, pair_x = 1, pair_y = 3)

pairwise_plot(galaxy_x, galaxy_y, type = "cva", pair_x = 2)

pairwise_plot(iris_features, iris_class)

Pairwise plots can be turned into interactive plotly graphs by setting interactive = TRUE.

pairwise_plot(digits_features, digits_class, pair_x = 1, pair_y = 3, interactive = TRUE)

pairwise_plot(galaxy_x, galaxy_y, pair_x = 2, interactive = TRUE)

pairwise_plot(iris_features, iris_class, interactive = TRUE)

## 3D Plots

```r
threewise_plot(digits_features, digits_class, type = "pca")
threewise_plot(galaxy_x, galaxy_y, type = "cva")
threewise_plot(digits_features, digits_class, type = "lda", k = 0.001)

Change Point Size with argument point_size

threewise_plot(iris_features, iris_class, type = "pca")
threewise_plot(iris_features, iris_class, point_size = 5)


Try the rrr package in your browser

Any scripts or data that you put into this service are public.

rrr documentation built on May 1, 2019, 9:16 p.m.