## ← Add a Scaling Layer - Data Analysis with R

• 2 Followers
• 24 Lines

### Get Embed Code x Embed video Use the following code to embed this video. See our usage guide for more details on embedding. Paste this in your document somewhere (closest to the closing body tag is preferable): ```<script type="text/javascript" src='https://amara.org/embedder-iframe'></script> ``` Paste this inside your HTML body, where you want to include the widget: ```<div class="amara-embed" data-url="http://www.youtube.com/watch?v=SsNYXdi3q-I" data-team="udacity"></div> ``` 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