the w orld of data v is u ali z ation
play

The w orld of data v is u ali z ation DATA VISU AL IZATION IN R - PowerPoint PPT Presentation

The w orld of data v is u ali z ation DATA VISU AL IZATION IN R Ron Pearson Instr u ctor Graphical tools help u s u nderstand a dataset O u r abilit y to interpret pa erns is a ke y strength T w o basic t y pes of data v is u ali z ations :


  1. The w orld of data v is u ali z ation DATA VISU AL IZATION IN R Ron Pearson Instr u ctor

  2. Graphical tools help u s u nderstand a dataset O u r abilit y to interpret pa � erns is a ke y strength T w o basic t y pes of data v is u ali z ations : E x plorator y v is u ali z ations help u s u nderstand the data E x planator y v is u ali z ations help u s share o u r u nderstanding w ith others R s u pports both t y pes of v is u ali z ations DATA VISUALIZATION IN R

  3. E x plorator y data v is u ali z ations Helps y o u see w hat is in y o u r data Le v el of detail : Keep as m u ch detail as possible Practical limit : Ho w m u ch can y o u see and interpret ? DATA VISUALIZATION IN R

  4. E x plorator y data v is u ali z ations # Exploratory plot of ChickWeight data frame plot(ChickWeight) DATA VISUALIZATION IN R

  5. E x planator y data v is u ali z ations Sho w s others w hat y o u’v e fo u nd in y o u r data Req u ires editorial decisions : Highlight the ke y feat u res y o u w ant to emphasi z e Eliminate e x traneo u s details DATA VISUALIZATION IN R

  6. E x planator y data v is u ali z ations DATA VISUALIZATION IN R

  7. E x planator y data v is u ali z ations DATA VISUALIZATION IN R

  8. Fo u r graphics s y stems in R Base graphics : Easiest to learn and foc u s of this co u rse Grid graphics : po w erf u l set of mod u les for b u ilding other tools La � ice graphics : general p u rpose s y stem based on grid graphics ggplot2 : the grammar of graphics DATA VISUALIZATION IN R

  9. Base graphics e x ample library(MASS) plot(UScereal$sugars, UScereal$Calories) title("plot(UScereal$sugars, UScereal$calories)") DATA VISUALIZATION IN R

  10. Base graphics e x ample DATA VISUALIZATION IN R

  11. Near eq u i v alent in grid graphics # Get the data and load the grid package library(MASS) x <- UScereal$sugars y <- UScereal$calories library(grid) # This is the grid code required to generate the plot pushViewport(plotViewport()) pushViewport(dataViewport(x, y)) grid.rect() grid.xaxis() grid.yaxis() grid.points(x, y) grid.text("UScereal$calories", x = unit(-3, "lines"), rot = 90) grid.text("UScereal$sugars", y = unit(-3, "lines"), rot = 0) popViewport(2) DATA VISUALIZATION IN R

  12. Near eq u i v alent in grid graphics DATA VISUALIZATION IN R

  13. Conditional scatterplot e x ample from lattice graphics library(MASS) library(lattice) xyplot(MPG.city ~ Horsepower | Cylinders, data = Cars93) DATA VISUALIZATION IN R

  14. Conditional scatterplot e x ample from lattice graphics DATA VISUALIZATION IN R

  15. E x ample ggplot 2 plot library(MASS) library(ggplot2) title <- "ggplot2 plot of \n UScereal$calories vs. \n UScereal$sugars" basePlot <- ggplot(UScereal, aes(x = sugars, y = calories)) basePlot + geom_point(shape = as.character(UScereal$shelf), size = 3) + annotate("text", label = title, x = 3, y = 400, colour = "red") DATA VISUALIZATION IN R

  16. E x ample ggplot 2 plot DATA VISUALIZATION IN R

  17. Let ' s practice ! DATA VISU AL IZATION IN R

  18. A pre v ie w of some more and less u sef u l techniq u es DATA VISU AL IZATION IN R Ron Pearson Instr u ctor

  19. Scatterplots in base graphics library(MASS) plot(Boston$rm, Boston$medv, main = "Scatterplot") DATA VISUALIZATION IN R

  20. Scatterplots in base graphics DATA VISUALIZATION IN R

  21. Scatterplots in base graphics DATA VISUALIZATION IN R

  22. Scatterplots in base graphics DATA VISUALIZATION IN R

  23. S u nflo w erplots in base graphics library(MASS) sunflowerplot(Boston$rad, Boston$tax, main = "Sunflowerplot") DATA VISUALIZATION IN R

  24. S u nflo w erplots in base graphics DATA VISUALIZATION IN R

  25. Bo x plots on base graphics library(MASS) boxplot(crim ~ rad, data = Boston, log = "y", las = 1 main = "Boxplot", xlab = "rad", ylab = "crim") DATA VISUALIZATION IN R

  26. Bo x plots on base graphics DATA VISUALIZATION IN R

  27. Mosaicplots in base graphics mosaicplot(cyl ~ gear, data = mtcars, main = "Mosaicplot") DATA VISUALIZATION IN R

  28. Some plot t y pes are more u sef u l than others DATA VISUALIZATION IN R

  29. Base R plots can be enhanced in man y w a y s High le v el f u nctions like plot() Feat u res can be added to a plot The points() f u nction adds points The lines() f u nction adds lines , u s u all y c u r v ed The text() f u nction adds labels Using di � erent colors - Chapter 5 co v ers this in detail DATA VISUALIZATION IN R

  30. Base R plots can be enhanced in man y w a y s DATA VISUALIZATION IN R

  31. Base R plots can be enhanced in man y w a y s DATA VISUALIZATION IN R

  32. Base R plots can be enhanced in man y w a y s The par() f u nction sets man y graphic parameters One u sef u l parameter is mfrow , w hich sets u p plot arra y s This is disc u ssed in Chapter 4 DATA VISUALIZATION IN R

  33. Base R plots can be enhanced in man y w a y s DATA VISUALIZATION IN R

  34. Base R plots can be enhanced in man y w a y s DATA VISUALIZATION IN R

  35. Let ' s practice ! DATA VISU AL IZATION IN R

Recommend


More recommend