Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Add a Scaling Layer - Data Analysis with R

Get Embed Code
5 Languages

Showing Revision 2 created 05/25/2016 by Udacity Robot.

  1. If you watched the solution video, you would have noticed that I
  2. used two different methods for transforming our variable. The first method used
  3. a wrapper right around the variable, and then the second used a
  4. scaling layer. Let's look at the differences between these two plots and
  5. see what the two adjustments really do. I'm going to save this first
  6. plot into log scale and I'm going to save the second plot into
  7. count scale. I'm going to use each of these variables and pass it
  8. to grid.arrange, so that way I can plot them side by side, and
  9. that's why the ncal is equal to two. Running this code,
  10. we can see that we get our two histograms. When looking
  11. at the two plots, we can see that the difference is
  12. really in the x axis labeling. Using scale_x_log10 will label the axis
  13. in actual friend_counts. Whereas using the log10 wrapper will label the
  14. x axis in log units. This is just something to keep
  15. in mind as you make more plots. In general, I think
  16. it's easier to think about actual counts, so that's why I prefer
  17. using the scale_x_log10 as a layer. Now, this does
  18. mean that you'll need to learn the ggplot syntax, but
  19. don't worry, you'll have plenty of practice in lesson
  20. four, and if you're feeling really adventurous, you can add
  21. a layer to any of the plots that you
  22. create. So, take our original histogram for friend count. Let's
  23. just add scale_x_log10 to it, and there you go. You
  24. have it, the new histogram transformed using log base 10.