Hey folks, I have long since given up trying to anticipate what types of videos will resonate with people on YouTube. One of my most popular videos shows people how to make stacked bar plots. Throughout it, I tell people that these are a horrible way to visualize data. It’s my third most viewed video. I thought a video on slope plots would be popular. Nope. People panned last week’s episode. But Venn diagrams - holy cats! People are really geeking out about this week’s episodes on Venn diagrams. Who knows. All I can do is keep putting out videos that I think are fun to make and that I think have potential to help you all learn to use {ggplot2} and related packages to make compelling figures. Honestly, I’m still surprised people watch the videos at all. Thank you. Can you tell me the last time you pronounced “abracdabra!”, squeezed a good luck charm, hit “Run” at just the right angle and hoped that your R code gave you what you were expecting? I’d love it if you emailed me where you find yourself doing this the most. A few weeks ago, I was working with some people on my floor doing a mob programming exercise. I really find these activities really give me a lot of energy and enthusiasm for R. Participants let their guards down a bit and are willing to be honest about what they do and don’t know. Because others in the room are in a similar position, it often results in people being willing to make themselves more vulnerable. Everyone has a great sense of humor about their successes and failures. I was struck by a comment one participant made. It was to the effect that “my strategy is to try a bunch of things and hope that some type of magic happens”. I see this a lot when I’m teaching workshops or when I’m looking at R code from people in my research group. People will try everything and hope for the best. When it works, they aren’t really sure why it worked. When it doesn’t work, they aren’t really sure why it didn’t work. What is magic? According to Merriam-Webster, magic is “the use of means (such as charms or spells) believed to have supernatural power over natural forces”. In other words, we effectively shout, “Abracadabra!”, click “Run”, and hope for our desired plot. Or at least no error messages. Trust me on this: there is no magic in R. If something seems “magical” to you about R, I encourage you to dig deep and figure out why something works or doesn’t work. There are a couple of reasons I make this suggestion. First, when you rely on magic, you aren’t learning anything. If you get an error or warning message, I want you to either modify the code to remove the message or be able to tell your neighbor why you are ok with leaving the warning. I try to demonstrate this in my videos by removing all possible warning messages by cleaning up the logic of my code. This week, you may have noticed I let a warning message go. I was using Second, when you rely on magic, you can’t be confident that what you are doing is actually correct. A lot of code I look at shows signs of someone who has “hacked” their code to bend to their will. It starts looking pretty ugly. A sign of this is when someone uses three techniques to do the same thing in their code. For example, they may use a for loop, Ultimately, accepting magic is like accepting a “black box”. We don’t know how it works, but we know it works and that’s good enough for us. As a personal example, in last week’s videos I used functions from {ggrepel}. This function allows you to place text in a plot so that the text doesn’t overlap other text or geoms. How does it work? Magic? To some degree I’m willing to accept that as an answer. But what if a label isn’t moving where I think it should? What if a label moves every time I run the command? How could I better understand how the arguments worked to better place a label? By moving beyond the magic. At a minimum I could read the documentation and look at other examples. I could look at the package’s “Related Work” page and read more documentation about the algorithms the package implements. The lesson I want to leave you with is to resist being content with “magic” as an answer. If you peel back the layer of magic each time “abracadabra!” gets you somewhere, you’ll be a far more confident programmer. That’s what I want for myself, the people in my research group, and for you. Here’s a bit of homework: see if you can explain the difference between setting the x-axis (or y-axis) limits using
|
Hey folks, I’m really grateful for the people who have emailed me recently to thank me for making the recreation and makeover videos. I’ve been excited to see the types of figures some of you are trying to make. It’s really been a great part of this work for me. Thank you! Eric Hill is a loyal Riffomonas Channel viewer who recently sent me an animation he made using the p5.js platform. The animation shows his son’s performance relative to other runners in the prestigious Nike Cross Nationals...
Hey folks, One of the benefits of sending out these newsletters and making my YouTube videos is that I get a ton of practice. I can’t emphasize how much practice has paid off in learning to use dplyr, ggplot2, and other packages. Reproducing published figures has really helped me to dive into parts of ggplot2 that I wouldn’t normally use because I make plots that use the features of ggplot2 that I know. By expanding my knowledge of ggplot2, I’m finding that the plots I make from scratch are...
Hey folks, I hope you’re enjoying my new approach of integrating the newsletter with my YouTube videos. The feedback I’ve gotten has been very positive. Thank you! I’d love it if you were to reply to this email with a link to the most recent figure you found in your reading of the literature or popular media. This week, I’m sharing with you Figure 5D from a paper recently published in mSystems by Charlie Bayne and colleagues where they looked at the effect of interactions between tryptophan...