The essential functions of R cheatsheet

80% of everything you need on two pages

👇 Download link is at the bottom of the post 👇

Something that I quickly came to learn as an ecologist using R is that out of the hundreds (possibly thousands?) of functions available in R, only a handful were those that I used frequently throughout my code.

I’m also learning to speak Spanish right now, and I’ve found that for learning a new language it is a good idea to start by focusing on the most common words, since only those few words account for a significant proportion of everything you’ll ever need to say.

Anyone familiar with Tim Ferriss probably knows about the 80-20 rule (Pareto’s principle) that he’s made popular throughout his books and podcasts. The rule simply states that 80% of results come from 20% of the work.

To apply that to learning a language, learning only a small proportion of words (20%) will allow you to say a large proportion (80%) what you’d ever need to say. Now, these percentages might not be exactly the same for every application, but hopefully you get the point.

Now back to R! So, that’s what I did with all the functions I use in R. I found the “20%” of functions that I ever used in ecology that gave me the most results. In other words, if you learn these functions (51 functions to be exact), you will be well on your way to do almost anything you need to do with your data. And if there’s something missing, that will be easy to learn when you need it.

So here is my version 1.0 of a cheat sheet on the essential functions of R (for ecology). Please enjoy and share! Notice a typo? Let me know in the comments below.

The ESSENTIAL functions of R
🐝 (for ecology) 🌱
Enter your email to get the best cheat sheet you'll ever need for working with R as an ecologist
(I'll also be sure to let you know when other resources become available)
*By clicking "GET MY CHEAT SHEET NOW" you are agreeing to receive email notifications from R for Ecology and you can unsubscribe at any time.


If you liked this post and want to learn more, then check out my online course on the complete basics of R for ecology:

Also be sure to check out R-bloggers for other great tutorials on learning R

M ↓   Markdown
E
expebarroso
0 points
33 days ago

Thanks

?
Anonymous
0 points
11 months ago

Thanks a lot!

L
Lucas Barreira
0 points
15 months ago

thank you!

M
Martina Höbartner
0 points
16 months ago

Thank you :)

M
Mahammad Aliyev
0 points
18 months ago

Thank you very much for your effort!

?
Anonymous
0 points
20 months ago

Thank you

?
Anonymous
0 points
20 months ago

Thx

K
Kim Alex
0 points
21 months ago

thanks!

?
Anonymous
0 points
21 months ago

Thank you

?
Anonymous
0 points
22 months ago

Thank you!

?
Anonymous
1 point
22 months ago

thanks

?
Anonymous
1 point
23 months ago

Thanks

?
Anonymous
1 point
23 months ago

Thanks a Lot!

?
Anonymous
1 point
23 months ago

Thanks from Poland!

?
Anonymous
1 point
23 months ago

Thanks a lot

?
Anonymous
1 point
23 months ago

Thanks a lot from Lebanon

?
Anonymous
1 point
23 months ago

Thanks a lot!

B
Bob Mrotek
0 points
3 years ago
?
Anonymous
0 points
4 years ago

Thank you very much, this is helping me to work on my data! -- From Indonesia

Watch out with setwd() or Jenny Bryan will burn your computer down 😜 https://www.tidyverse.org/blog/2017/12/workflow-vs-script/

L
Luka Negoita
0 points
4 years ago

hahaha yeah... maybe I decided to keep it in there just to make the point. Thanks for sharing that!

?
Anonymous
1 point
4 years ago

i always just use ? instead of help(). Saves a bit of typing! Maybe worth mentioning gsub with grepl lastly, a vote for %in% good stuff!

L
Luka Negoita
0 points
4 years ago

Great suggestions! I'll keep these in mind for the next version. Thanks!

?
Anonymous
1 point
4 years ago

I wonder if it'd be useful to write the non-base functions as pkgname::fn() rather than "fn() uses pkgname"? For example, lubridate::ymd(), dplyr:: mutate(), etc. It's more in keeping with the recommended style when developing packages and is safer to use in scripts, especially for simple function names that might be used in more than one package.

And thanks for creating this! It'll be very useful for teaching.

L
Luka Negoita
0 points
4 years ago

Thanks for the suggestion. Yeah, that makes sense. For now the goal was to keep things simple, but perhaps I'll make a cheatsheet soon with the best practices (such as what you recommend here).

I
Ilja Kocken
1 point
4 years ago

Hi, great summary! But if you're recommending some tidyverse functions (tibble, left_join, select, filter, mutate), why not also recommend the infinitely easier to use read_csv and write_csv from readr? I can see why you'd stick to base plotting in favour of ggplot2 for such an overview, but those two functions are so much more beginner friendly IMO that I would definitely include them (when TA'ing, most issues were with people using ;-separated files etc.)

L
Luka Negoita
0 points
4 years ago

Hi Ilja, and thank you so much for that suggestion. You are probably totally right. The reason I stuck to read. and write.csv for now is because those functions are always taught so commonly at the beginning of most courses that I didn't want to make it that much more confusing for someone just starting out (i.e., by having them learn yet another loading data function). That said, you make a very good point so I'll definitely consider that for the next version of this cheatsheet. Definitely a work in progress!

I
Ilja Kocken
0 points
4 years ago

Cool! Yeah, it's a hard balance between keeping it simple and keeping it powerful. I loved these two contrasting articles on the subject: why NOT to teach tidyverse to beginners (keep it simple): https://github.com/matloff/TidyverseSkeptic DO teach tidyverse to beginners (show powerful examples): http://varianceexplained.org/r/teach-tidyverse/

L
Luka Negoita
1 point
4 years ago

Oh that's really cool! Thanks for sharing those articles. I'll have a read.

Related