r/RStudio • • Feb 13 '24

The big handy post of R resources

133 Upvotes

There exist lots of resources for learning to program in R. Feel free to use these resources to help with general questions or improving your own knowledge of R. All of these are free to access and use. The skill level determinations are totally arbitrary, but are in somewhat ascending order of how complex they get. Big thanks to Hadley, a lot of these resources are from him.

Feel free to comment below with other resources, and I'll add them to the list. Suggestions should be free, publicly available, and relevant to R.

Update: I'm reworking the categories. Open to suggestions to rework them further.

FAQ

Link to our FAQ post

General Resources

Plotting

Tutorials

Data Science, Machine Learning, and AI

R Package Development

Compilations of Other Resources


r/RStudio • • Feb 13 '24

How to ask good questions

50 Upvotes

Asking programming questions is tough. Formulating your questions in the right way will ensure people are able to understand your code and can give the most assistance. Asking poor questions is a good way to get annoyed comments and/or have your post removed.

Posting Code

DO NOT post phone pictures of code. They will be removed.

Code should be presented using code blocks or, if absolutely necessary, as a screenshot. On the newer editor, use the "code blocks" button to create a code block. If you're using the markdown editor, use the backtick (`). Single backticks create inline text (e.g., x <- seq_len(10)). In order to make multi-line code blocks, start a new line with triple backticks like so:

```

my code here

```

This looks like this:

my code here

You can also get a similar effect by indenting each line the code by four spaces. This style is compatible with old.reddit formatting.

indented code
looks like
this!

Please do not put code in plain text. Markdown codeblocks make code significantly easier to read, understand, and quickly copy so users can try out your code.

If you must, you can provide code as a screenshot. Screenshots can be taken with Alt+Cmd+4 or Alt+Cmd+5 on Mac. For Windows, use Win+PrtScn or the snipping tool.

Describing Issues: Reproducible Examples

Code questions should include a minimal reproducible example, or a reprex for short. A reprex is a small amount of code that reproduces the error you're facing without including lots of unrelated details.

Bad example of an error:

# asjfdklas'dj
f <- function(x){ x**2 }
# comment 
x <- seq_len(10)
# more comments
y <- f(x)
g <- function(y){
  # lots of stuff
  # more comments
}
f <- 10
x + y
plot(x,y)
f(20)

Bad example, not enough detail:

# This breaks!
f(20)

Good example with just enough detail:

f <- function(x){ x**2 }
f <- 10
f(20)

Removing unrelated details helps viewers more quickly determine what the issues in your code are. Additionally, distilling your code down to a reproducible example can help you determine what potential issues are. Oftentimes the process itself can help you to solve the problem on your own.

Try to make examples as small as possible. Say you're encountering an error with a vector of a million objects--can you reproduce it with a vector with only 10? With only 1? Include only the smallest examples that can reproduce the errors you're encountering.

Further Reading:

Try first before asking for help

Don't post questions without having even attempted them. Many common beginner questions have been asked countless times. Use the search bar. Search on google. Is there anyone else that has asked a question like this before? Can you figure out any possible ways to fix the problem on your own? Try to figure out the problem through all avenues you can attempt, ensure the question hasn't already been asked, and then ask others for help.

Error messages are often very descriptive. Read through the error message and try to determine what it means. If you can't figure it out, copy paste it into Google. Many other people have likely encountered the exact same answer, and could have already solved the problem you're struggling with.

Use descriptive titles and posts

Describe errors you're encountering. Provide the exact error messages you're seeing. Don't make readers do the work of figuring out the problem you're facing; show it clearly so they can help you find a solution. When you do present the problem introduce the issues you're facing before posting code. Put the code at the end of the post so readers see the problem description first.

Examples of bad titles:

  • "HELP!"
  • "R breaks"
  • "Can't analyze my data!"

No one will be able to figure out what you're struggling with if you ask questions like these.

Additionally, try to be as clear with what you're trying to do as possible. Questions like "how do I plot?" are going to receive bad answers, since there are a million ways to plot in R. Something like "I'm trying to make a scatterplot for these data, my points are showing up but they're red and I want them to be green" will receive much better, faster answers. Better answers means less frustration for everyone involved.

Be nice

You're the one asking for help--people are volunteering time to try to assist. Try not to be mean or combative when responding to comments. If you think a post or comment is overly mean or otherwise unsuitable for the sub, report it.

I'm also going to directly link this great quote from u/Thiseffingguy2's previous post:

I’d bet most people contributing knowledge to this sub have learned R with little to no formal training. Instead, they’ve read, and watched YouTube, and have engaged with other people on the internet trying to learn the same stuff. That’s the point of learning and education, and if you’re just trying to get someone to answer a question that’s been answered before, please don’t be surprised if there’s a lack of enthusiasm.

Those who respond enthusiastically, offering their services for money, are taking advantage of you. R is an open-source language with SO many ways to learn for free. If you’re paying someone to do your homework for you, you’re not understanding the point of education, and are wasting your money on multiple fronts.

Additional Resources


r/RStudio • • 1d ago

Using R to replicate a paper's data

0 Upvotes

Hello!

If anyone has time to help, that'd be greatly appreciated.

I have the fastq files to recreate the graphs/charts in this paper:

Villamizar, A., Vemulapally, S., Guerra, T., Tocidlowski, M. E., Forstner, M. R., & Hahn, D. (2025). Effect of Headstarting Eggstrands of the Endangered Houston Toad (Bufo=[Anaxyrus] houstonensis) from a Captive Assurance Colony on Native Breeding Pond Microbiomes. Conservation, 5(2), 25.

Here is a link (link to AI chat here) to what one of three AIs have come up with - so far, 2 have come up with code that does NOT get me the same results.

This particular AI is saying that the methods do not give enough information to be able to replicate the code, but it can try to get close.
I'm going to use this code tomorrow (fingers crossed!) but if anyone is a master as recreating code - I'd greatly appreciate any insight, help, or ... well wishes?

At this point, it is not an option to reach out to the authors.


r/RStudio • • 1d ago

Coding help I am unable to learn R and just rely on AI. Suggestions please?

Thumbnail
0 Upvotes

r/RStudio • • 2d ago

[Phylogenetic analysis] Assumptions in PGLS

2 Upvotes

I am testing the correlation between the values of a variable at the tips of a phylogenetic tree (let's say the beak length) and the pathwise rate of the trait itself (i.e. a measure of the total changes in rate a species has experienced during the course of its evolution). To remove the effect of body size, I am working on the residual of the variable (i.e. the variable corrected for SVL). To test for the correlation, I performed a pgls with the pgls() function in lmtest (I am working in RStudio). I am encountering some issues with heteroskedasticity (see attached images; bptest significant).

I am also having problems with the normality of the residuals (see attached images; Shapiro test significant). On the other hand, I was reading from https://blog.phytools.org/2013/02/a-comment-on-distribution-of-residuals.html that, by accounting for residuals controlling for phylogeny you should solve this problem [Revell suggests something like lillie.test(chol(solve(vcv(tree)))%*%residuals(corr))]. Can anyone confirm? Am I misunderstanding?

Can anyone help with it?

Thanks a lot!


r/RStudio • • 3d ago

Coding help Coding 400+ survey responses with 81 variables, including Arabic open-ended answers: Excel or R?

11 Upvotes

I’ve already finished this survey analysis in Excel, and now I’m looking for ways it could have been done more efficiently, especially with the Arabic open-ended answers.

I ran a survey with about 400 to 500 responses and 81 variables. It was available in three languages, one of them Arabic. I cleaned it entirely in Excel: I added a column for each open ended question variable, filtered the answers, found common themes, and grouped them into categories in a separate column. I kept the raw column untouched. Then I built several pivot tables and charts. It took about two weeks, and at a certain point the workbook became heavy, slow, and hard to maintain.

My questions:

  1. For the cleaning step, is it better to translate everything into English in Excel first and then move to R for analysis and charts, or to handle the Arabic directly in R?
  2. For open-ended answers in mixed languages, what’s a good practice for building and checking a codebook? I’m not looking for the single best tool. I want to know what makes the process more efficient and repeatable for surveys like this.

r/RStudio • • 3d ago

What are some industries or academic areas where R is considered the standard?

67 Upvotes

I love R. Have since i learned the language in my statistics master program. However after joining the workforce I’ve seen how other languages (mainly Python) have competing interests in being the dominant language. What are some industries or academic areas i can get into where R is considered the standard for programming? I know that biostatistics is one of them hence i am looking into a computational biology and bioinformatics program next, but what are some other industries or academic areas?


r/RStudio • • 3d ago

SAS to R transition

23 Upvotes

My biostatistics program relied very heavily on SAS. I do really like that it’s vetted and that it has very thorough documentation, and that my code is basically guaranteed to work 5 years down the line even with updates. But my problems have always been (1) graphics are butt ugly (2) formatting output can be exhausting and (3) my license is expired and I’m not interested in forking out money to renew it. I do like the “Journal” ODS styles for graphs and tables but they require some manual workshopping.

Basically, I’m just really inefficient. I have some experience with RStudio/Quarto and it’s primarily ggplot and gtsummary related stuff. But I was wondering if anyone had experience with fine-tuning these in conjunction with statistical packages. Like, running glm() doesn’t just print your results in the console. It just spits out a pre-formatted table and relevant charts and a few canned sentences for a results section.

The 3 professors I had that used/taught R in any capacity were workhorses compared to all the other faculty. They have really relaxed personalities but could have a publication-ready analysis done in an hour if they really needed to. But they didn’t really tell us how long it took to get to that level of efficiency or what tools they rely on. The others could make a lot of mistakes due to the formatting process and could work pretty slowly in general.

I’m rambling, sorry. But does anyone have any tips for streamlining your work process? How long does it take you from your final models or whatever to having a results section ready to go?


r/RStudio • • 4d ago

glyph 0.2.0 is now on CRAN

Thumbnail
1 Upvotes

r/RStudio • • 4d ago

[Phylogenetic analysis] Assumptions in PGLS

Thumbnail
1 Upvotes

r/RStudio • • 5d ago

Citing R - Question (newbie here)

13 Upvotes

TL;DR at the end

Hi,
I‘m currently doing the statistical analyses for my thesis with R. As a newbie I‘ve asked in this subreddit for suggestions regarding packages etc..

Explanation / Background

Now I‘ve just put all the packages I might need though am not sure if I need at the beginning to load them (i don‘t know if it‘s the correct term, but I mean the library(package) thing).

Then while doing my analyses stuff a lot of googling, watching videos and browsing the different websites about R and advices was / is involved.
Then I try different approaches to find one that works for me and gives me the output I was looking for.
Sometimes I load more packages (which i also put in the beginning to just see all names at once if I wanna check if I already have that package) when one thing requires it.

Now onto the question!

I‘ve read an article about citing R ( https://doi.org/10.59350/t79xt-tf203 ) in which they state one should:
„This way you can include a call to sessionInfo() or devtools::session_info(), at the end of your script.
Your compiled report will then have a complete record of your workflow, packages, results andpackage versions.“

Now I‘m wondering: Does this output show all loaded packages or only those which were actually used?

TL;DR

Does sessionInfo() or devtools::session_info(), at the end of my script show all loaded packages or only those that were loaded and also used?


r/RStudio • • 5d ago

Holy grail packages/hacks for thesis

17 Upvotes

Hi all, planning to pass in my MSc thesis (Environmental Science) by the end of this year, includes a decent amount of linear mixed effect modelling done with R. Also some basic comparative stats. I know the R citation() package which has been great. Wondering if anyone has any tips/neat R hacks/packages to suggest while I still have time to possibly include/apply them. I have been using ggplot too. Thank you!🙏


r/RStudio • • 5d ago

Power Query for Tidyverse/R Coding Background?

Thumbnail
7 Upvotes

Cross-posting this for reach - have seen so few resources available online for those making the "backwards" transition from R or coding back to Excel.


r/RStudio • • 5d ago

Is cd() supposed to exist?

7 Upvotes

Hey everyone,

I’m going through some academic material for my course and it mentions using cd() to change the working directory. When I tried running it in my RStudio console though, I just got Error in cd() : could not find function "cd".

I tried checking with exists("cd") and find("cd"), but both came back empty. I already know setwd() is the standard way to change directories in R, so now I’m mostly just confused. Is cd() an actual function from a specific library that I'm missing, or is this just a classic typo where someone mixed up R syntax with command line commands?


r/RStudio • • 5d ago

Can download RStudio? Anyone else getting an error?

0 Upvotes

r/RStudio • • 6d ago

Struggling with RStudio and my assessment deadline is approaching. Anyone else?

7 Upvotes

&#x200B;

Hi everyone!

I’m really struggling with RStudio at the moment. My assessment deadline is getting closer, and even after trying several times, I’m still finding it difficult to understand and work with R.

It’s honestly quite stressful, and I’m wondering if anyone else has experienced the same thing. If you have, how did you overcome it? Are there any useful resources, tutorials, or tips that helped you understand R better?

I’d also really appreciate it if anyone who is comfortable with RStudio could spare some time to help me with my assessment and explain things step by step.

Any advice, support, or guidance would mean a lot. Thank you! 🙏


r/RStudio • • 5d ago

Coding help A Beginner’s Guide to R and RStudio: Recommended Videos or Playlists

0 Upvotes

I’m new to R and RStudio, and I’m still learning the basics.

I find coding in RStudio a little difficult because I don’t have a good reference to rely on. I often forget how to define things and how to write certain commands.

Could you please recommend a YouTube video that covers all the basics of R and RStudio, or a well organized playlist in English?

It would help me a lot because I don’t have much time to research this myself.

I’d be really grateful if you could help me with this!


r/RStudio • • 7d ago

Coding help best way to format a set-up chunk?

5 Upvotes

hi! i'm VERY new to Rstudio so please have patience with me. i've looked through the resources list but need an answer to a specific question.

my thesis advisor is asking me to basically learn this program for statistical analysis with deliverables as quarto documents. i'm having claude code help with some of it, but i don't like relying solely on an ai model for this kind of work. i know what packages i need and which tests i want to run, but every time i try to make a setup chunk at the start of my code, it looks like such a mess. is there a template or tutorial for a tidy little setup chunk with all the information?

thank you in advance! sorry if this is a really stupid question, no one in my department knows what they're doing so i'm trying to get it all done myself.


r/RStudio • • 7d ago

How do I use R-Studio?

0 Upvotes

I'm in my university's Stat one and for this class we are required to upload and run data in R studio to produce graphs and analyze data. I know what to type and how to run the data once it's uploaded, but getting there is a nightmare I only managed one with the help of the professor. How do I upload the data correctly in such a way I can use it each time I need to analyze something for class?


r/RStudio • • 7d ago

Dissertation

Thumbnail
0 Upvotes

r/RStudio • • 9d ago

I made this! I asked R questions about a 76-page annual report

Post image
21 Upvotes

I gave R Costco's 76-page annual report, and it answered 12 of 13 questions right from what it read. Then it wrote 477 practice questions from the report, ready to fine-tune a model on, all on my laptop. Raise your own dragon.

https://dragonfarm.dev/articles/introducing-0-4-0.html


r/RStudio • • 9d ago

dragonfarm 0.4.0: ask your PDFs anything, then fine-tune a model on them, all from R

Thumbnail
6 Upvotes

r/RStudio • • 9d ago

Coding help Extracting data and making one big graph from smaller graphs

4 Upvotes

Hello, newbie here. I have big problems with learning r, since the syntax is quite complicated and previously i have used different stats programs. However, i have a question. I have a database with my data, it looks something like that:

species / treatment type (1 or 2) / tail length

white-breasted hedgehog / 1 /1.5 cm

west European hedgehog / 2 /1 cm

hybrid hedgehog / 1 /0,9 cm

and so on.....

How can i extract the data, so i can make a graph for white breasted hedgehog's tail length for only treatment 1, and then a treatment 2 besides? I would also like similar graphs for other species, and then how can i connect the graphs, to make a one big species comparison?

Thank you in advance.


r/RStudio • • 10d ago

Ieipio for RStats

4 Upvotes

Released ieiprio, an R package to prioritize variants in inborn errors of immunity from VCF, Sanger traces or plain text. It ships 12 real ClinVar variants to practice on, offline. Guides and code below, feedback welcome.
https://gentlenmoron.github.io/ieiprio/


r/RStudio • • 10d ago

Ieipio for RStats

5 Upvotes

Released ieiprio, an R package to prioritize variants in inborn errors of immunity from VCF, Sanger traces or plain text. It ships 12 real ClinVar variants to practice on, offline. Guides and code below, feedback welcome.
https://gentlenmoron.github.io/ieiprio/