1. Oktober 2017

Description

This R Markdown presentation is part of cursera DataScientist course Developing Data Products second Peer Assignment.

I will show how a graph generated by plotly seems like a picture.

Data

I found following sequence of 920 numbers:

1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,5,5,1,1,1,5,5,1,5,5,5,5,5,5,5,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,5,5,5,5,5,1,1,1,
1,5,5,1,1,1,5,5,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,5,5,1,1,1,
1,5,5,1,1,1,5,5,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,5,5,1,1,1,
1,5,5,5,5,5,5,5,1,5,5,5,5,5,5,5,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,5,5,1,1,1,
1,5,5,1,1,1,5,5,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,5,5,1,1,1,
1,5,5,1,1,1,5,5,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,5,5,1,1,1,
1,5,5,1,1,1,5,5,1,5,5,5,5,5,5,5,1,1,5,5,5,5,5,5,5,5,1,5,5,5,5,5,5,5,5,1,5,5,5,5,5,5,5,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,2,2,1,1,1,1,1,2,2,1,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,1,1,2,2,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,
1,2,2,1,1,2,1,1,2,2,1,1,2,2,1,1,1,2,2,1,2,2,1,1,2,2,1,1,2,2,1,1,1,1,1,1,1,2,2,1,1,2,2,1,1,1,
1,2,2,1,2,2,2,1,2,2,1,1,2,2,1,1,1,2,2,1,2,2,1,2,2,1,1,1,2,2,1,1,1,1,1,1,1,2,2,1,1,1,2,2,1,1,
1,2,2,2,2,1,2,2,2,2,1,1,2,2,1,1,1,2,2,1,2,2,2,2,1,1,1,1,2,2,1,1,1,1,1,1,1,2,2,1,1,1,2,2,1,1,
1,2,2,2,2,1,1,2,2,2,1,1,2,2,1,1,1,2,2,1,2,2,1,2,2,1,1,1,2,2,1,1,1,1,1,1,1,2,2,1,1,1,2,2,1,1,
1,2,2,2,1,1,1,2,2,2,1,1,2,2,1,1,1,2,2,1,2,2,1,1,2,2,1,1,2,2,1,1,1,1,1,1,1,2,2,1,1,2,2,1,1,1,
1,2,2,1,1,1,1,1,2,2,1,1,2,2,2,2,2,2,2,1,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,1,2,2,2,2,2,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

Questions:

  • What is the meaning of the data?
  • Did there exist a pattern?

Analysing approach

  1. load data into R
  2. print a scatter plot with plotly
  3. try to finde pattern
  4. convert data to a matrix and print as heatmap with plotly
  5. try to finde pattern
  6. convert data into an other matrix and print as heatmap with plotly
  7. conclusion
  8. summary

Load data into R

# load data as vector into R
n_list <- c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  1,5,5,1,1,1,5,5,1,5,5,5,5,5,5,5,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,5,5,5,5,5,1,1,1,
  1,5,5,1,1,1,5,5,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,5,5,1,1,1,
  1,5,5,1,1,1,5,5,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,5,5,1,1,1,
  1,5,5,5,5,5,5,5,1,5,5,5,5,5,5,5,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,5,5,1,1,1,
  1,5,5,1,1,1,5,5,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,5,5,1,1,1,
  1,5,5,1,1,1,5,5,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,1,1,1,1,5,5,1,1,1,5,5,1,1,1,
  1,5,5,1,1,1,5,5,1,5,5,5,5,5,5,5,1,1,5,5,5,5,5,5,5,5,1,5,5,5,5,5,5,5,5,1,5,5,5,5,5,5,5,1,1,1,
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  1,2,2,1,1,1,1,1,2,2,1,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,1,1,2,2,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,
  1,2,2,1,1,2,1,1,2,2,1,1,2,2,1,1,1,2,2,1,2,2,1,1,2,2,1,1,2,2,1,1,1,1,1,1,1,2,2,1,1,2,2,1,1,1,
  1,2,2,1,2,2,2,1,2,2,1,1,2,2,1,1,1,2,2,1,2,2,1,2,2,1,1,1,2,2,1,1,1,1,1,1,1,2,2,1,1,1,2,2,1,1,
  1,2,2,2,2,1,2,2,2,2,1,1,2,2,1,1,1,2,2,1,2,2,2,2,1,1,1,1,2,2,1,1,1,1,1,1,1,2,2,1,1,1,2,2,1,1,
  1,2,2,2,2,1,1,2,2,2,1,1,2,2,1,1,1,2,2,1,2,2,1,2,2,1,1,1,2,2,1,1,1,1,1,1,1,2,2,1,1,1,2,2,1,1,
  1,2,2,2,1,1,1,2,2,2,1,1,2,2,1,1,1,2,2,1,2,2,1,1,2,2,1,1,2,2,1,1,1,1,1,1,1,2,2,1,1,2,2,1,1,1,
  1,2,2,1,1,1,1,1,2,2,1,1,2,2,2,2,2,2,2,1,2,2,1,1,2,2,1,1,2,2,2,2,2,2,2,2,1,2,2,2,2,2,1,1,1,1,
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)

Print a scatter plot with plotly

Print a scatter plot with plotly

Try to finde patter

By looking at the prior scatter plot we can find folloing facts:

  • only 3 different values
  • majority of values is 1
  • the values
  • toggle between 1 and 5
  • toggle between 1 and 3
  • did not toggle between 3 and 5
  • … and same more facts

Convert data to a matrix and print as heatmap with plotly

Load data in a 20x46 matrix.

# the vector with length 920 can loaded into a 20x46 matrix 
n_matrix <- matrix(n_list,nrow = 20, ncol = 46)
# plot matrix as heatmap
plot_ly(z=n_matrix, type="heatmap")

Convert data to a matrix and print as heatmap with plotly

Try to finde pattern

By looking at the prior heatmap plot we can find folloing facts:

  • there are same cluster
  • it seems that there is a pattern but it is not clear visible
  • … and same more facts

We will rotate the matrix by 90 degree and print it again as heatmap.

Convert data into an other matrix and print as heatmap with plotly

Load data in a 46x20 matrix.

# the vector with length 920 can loaded into a 46x20 matrix 
n_matrix <- matrix(n_list,nrow = 46, ncol = 20)
# rotate matrix
rotate_matrix <- apply(t(n_matrix),2,rev)
# plot matrix as heatmap
plot_ly(z=rotate_matrix, type="heatmap")

Convert data into an other matrix and print as heatmap with plotly

Conclusion

Summary

You can hide a lot of information in data. It is hard to interpert the data without knowing nothing about the data.

I hope you enjoyed this small presentation.