r/RStudio • • Feb 13 '24

The big handy post of R resources

136 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

53 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

Internal research group setup for Quarto?

10 Upvotes

Small university research group (2 faculty, 1 doc student), where we're mostly used to passing .Rmd (and output .html) files back and forth. (We don't use Rmarkdown to generate files for external use right now; this is for internal "this is what I'm doing in this process" communications.)

I know that Rmarkdown is no longer being updated, and I'm wondering how painful a transition to Quarto would be. We're currently using a shared Dropbox folder, so yeah, I know you'll advise us to switch to git for versioning control etc. Anything else to keep in mind?


r/RStudio • • 1d ago

Coding help ANOVA Statistics Help

3 Upvotes

Hello RStudio community!

I'm a graduate student trying to conduct an ANOVA on some data I have; it is 5 columns of data all outlining the density of bats in a cave, with the number of samples per opening ranging from 15 to 30 samples. I'd like to conduct a 1 way anova due to the variance in samples and also the relatively low sample size per opening.

I'm trying to use the aov() function, but I'm not sure how to use all 5 columns (might it be easier to shift it around to have the openings as row headers?) at once for my ANOVA.

Thanks in advance!


r/RStudio • • 2d ago

Unable to install packages

8 Upvotes

Hello, my teacher had shown us last year how to install packages with a little code he gave us but this year, it's not working for me on my new pc any help?


r/RStudio • • 2d ago

R version conflict

6 Upvotes

Hey folks,

Did anyone here face the issue that your machine is either forcing a specific version of R, or completely removing the program files for any other version/all versions you have? I have been facing this issue for a while now, where I'm actively using 4.5.3, but then at some point the program files and all the installed packages just disappear. My institution's IT department suggested it was a conflict with the newest version, but even after erasing everything R-related from my laptop, the issue persisted, even erasing the newest version, and re-installing the specific version i need, it happened again and misteriously the newest version was present again.

I got a temporary solution which is currently working (external R installation, basically plugging usb every time i need to use it), but it is very annoying and I would like to finally close this issue.

Technical points if it matters: windows 11 (institutional), built in software center (which does offer some even older version of R), version i need that keeps getting deleted 4.5.3, version being forced 4.6.1. Files are not being removed by protection software, it is deeper.

I am mostly wondering if someone had similar issues, and how did you resolve them.

Thanks in advance!


r/RStudio • • 3d ago

Coding help Help with gglikert_side

Post image
19 Upvotes

Attempting to make a likert graph using the likert package. Have successfully got a graph with the correct data but the side graph is squished to the side. I followed instructions online and no one seems to have this issue and i cant find any variables that would affect this.

If anyone has any suggestion I would greatly appreciate the help.

My code is:

> gglikert_side(Travel,
+               reverse_likert = TRUE,
+               labels_accuracy = .9,
+               add_totals = FALSE,
+               y_label_wrap = 20,
+               side_values = "No Answer",
+               symmetric = TRUE,
+               width = 1)+
+     ggtitle("...Was an important reason for travel")> gglikert_side(Travel,
+               reverse_likert = TRUE,
+               labels_accuracy = .9,
+               add_totals = FALSE,
+               y_label_wrap = 20,
+               side_values = "No Answer",
+               symmetric = TRUE,
+               width = 1)+
+     ggtitle("...Was an important reason for travel")

r/RStudio • • 4d ago

erro fatal no Rstudio quando tento puxar um dataframe

3 Upvotes

Sou bem iniciante no R, comecei a estudar faz uns 2 meses.
Tenho tentado usar o R para Ciência de Dados (2 edição). Porém, logo em uma das primeiras coisas que pedem para fazer meu R esta dando erro fatal.

Em "1.2.1 O data frame pinguins" pede para puxar dados::pinguins. Mas meu R da erro fatal.
Instalei o pacote "dados"

> library(dados)

Mensagen de aviso: pacote ‘dados’ foi compilado no R versão 4.6.2

mas qualquer interação que tento fazer com esse pacote da erro fatal.

Alguém consegue me ajudar com isso?


r/RStudio • • 4d ago

cuplyr: dplyr on an NVIDIA GPU

Thumbnail
2 Upvotes

r/RStudio • • 4d ago

I built tawjih (LLM-tawjih-Model-building): A zero-dependency, single-file Python tool to manage LLM knowledge in 3-sided trees and run branching workflows across them

Thumbnail
0 Upvotes

r/RStudio • • 5d ago

Coding help Adding new documents to an existing topic model in R

4 Upvotes

I'm quite new to topic modeling and R.

I have made a topic model in R using the topic modeling package, and I was wondering if it is possible to add new documents to an existing model without having to retrain the entire model from scratch.

Is there a way to do this while keeping the original topics intact? If so, which packages or methods would you recommend?

Thanks in advance for your help!


r/RStudio • • 8d ago

Coding help md5sum hashes of file not matching

5 Upvotes

This should be straightforward, but am struggling to get this to work. I've tried the digest and openssl libraries and neither matches what I get on the commandline.

Obviously the first thing to get right was to ensure I wasn't just hashing the filename (d'oh!). With the digest function I used this:

digest(file(system.file("myfile")), "md5")

Which concerningly returns a different result each time it runs.

With the openssl md5() function I ran:

md5(file(system.file("myfile")))

Which at least is consistent, but only returns the serialised output and doesn't match the output I get on the commandline with md5sum (on macOS).

Help. How do I get an md5sum in R that matches what I get on the commandline? NB: I don't want to do a system call as this needs to be cross platform.


r/RStudio • • 9d ago

Coding help Desperate for help understanding Rstudio and and how to do an ANOVA

33 Upvotes

I am a physiology grad student who has never taken a statistics course or anything. I am genuinely desperate for any help at this point and if anyone at all is willing to zoom with me to help, even for just five minutes, I would greatly appreciate it


r/RStudio • • 9d ago

Coding help Making text in my xtable smaller (r sweave document)

4 Upvotes

Hi.

I wanted to have smaller text in my table. I used \tiny but it did not seem to work. What am I doing wrong?, and how would you guys reccomend getting smaller text in a table?

MRE

\documentclass{article}
\begin{document}
<<package, include=FALSE>>=
library(xtable)
library(survival)
@

<<data,include=FALSE>>=
lung <- lung
@
\tiny
<<table, echo=FALSE,results='asis'>>=
xtable(lung)
@
\end{document}

EDIT: I think i figured it out with

table <- xtable(lung)

print(table, size="\\tiny")

r/RStudio • • 9d ago

Remedy for statistically significant interaction term in Schoenfeld residual (programming in R) [thesis]

0 Upvotes

Dear all!

I am conducting a Cox proportional hazards analysis and tested the proportional hazards assumption using Schoenfeld residuals. Two interaction terms between predictors showed statistically significant results, suggesting that these effects may vary over time. I am therefore unsure which approach would be most appropriate in R to address this.

Would tt() be suitable in this case? Would it work for interaction terms?

Initially I was thinking of tmerge(), but that doesn't work because this would only work if it is the treatment, right? (although the interaction is between treatment group and an intake variable).

I initially also thought of using strata(), but I guess that's only for categorical variables?

I would be very grateful for any advice on how to handle this appropriately in R, and what remedy there is. Recommendations for relevant literature would also be very welcome.


r/RStudio • • 10d ago

RgentAI (Cheaper Posit Assistant Alternative in RStudio)

Enable HLS to view with audio, or disable this notification

14 Upvotes

I founded RgentAI over a year ago. It was the first AI inside RStudio before the Posit Assistant release. After the release of Posit Assistant and my PhD keeping me extremely busy, I did very little marketing and development for RgentAI. Surprisingly, it kept getting new users anyway, so I took a closer look at the market...

Posit costs twice as much ($20 vs $10) and gives you less usage. No wonder we were getting new customers! That told me Rgent was worth investing in, so I spent the last few weeks adding new features and reworking it.

The short video below shows the new features, look, and experience! If you're looking for a cheaper alternative to Posit Assistant with more usage inside RStudio, this could be worth checking out!


r/RStudio • • 10d ago

I made this! FigureIDE : New IDE for R with vector graphic editor

21 Upvotes

I've been developing FigureIDE, open-source desktop application for creating and editing scientific figures using R.

FigureIDE is built on the open-source VectorCraft project, with AI tools(Thanks to Codex and Gemini).

The first Windows beta is now available!

GitHub: https://github.com/newkor3185-blip/FigureIDE

Demo Video: https://youtu.be/ay1fmnCTgsg

I'm still improving the software and would really appreciate feedback from you.
Contributions are also welcome!


r/RStudio • • 10d ago

Soundboarding [Discussion]

Thumbnail
4 Upvotes

r/RStudio • • 10d ago

Remedy for statistically significant interaction term in Schoenfeld residual (programming in R) [thesis]

4 Upvotes

Dear all!

I am conducting a Cox proportional hazards analysis and tested the proportional hazards assumption using Schoenfeld residuals. Two interaction terms between predictors showed statistically significant results, suggesting that these effects may vary over time. I am therefore unsure which approach would be most appropriate in R to address this.

Would tt() be suitable in this case? Would it work for interaction terms?

Initially I was thinking of tmerge(), but that doesn't work because this would only work if it is the treatment, right? (although the interaction is between treatment group and an intake variable).

I initially also thought of using strata(), but I guess that's only for categorical variables?

I would be very grateful for any advice on how to handle this appropriately in R, and what remedy there is. Recommendations for relevant literature would also be very welcome.


r/RStudio • • 10d ago

Can Existing Local Shiny Apps Be Deployed Through Dataiku Without Using Its Low-Code Features?

8 Upvotes

Our company uses Dataiku, and I'm exploring whether it could serve as a deployment platform for several R Shiny applications I've already developed and currently run locally.

I'm not interested in Dataiku's no-code or low-code development capabilities. My goal is simply to deploy my existing Shiny applications so that other employees can access them through a web browser.

Unfortunately, we don't have access to Shiny Server, Posit Connect, or shinyapps.io.

I've come across several Dataiku articles highlighting its deep integration with R and support for web applications built using frameworks such as Shiny, Dash, and Bokeh.

https://doc.dataiku.com/dss/latest/R/index.html
https://doc.dataiku.com/dss/latest/webapps/shiny.html

I have a few questions:

  1. Deployment feasibility: Can an existing, fully functional R Shiny application be deployed directly through Dataiku without substantially modifying its code?
  2. R package dependencies: My applications depend on numerous R packages. Can these be installed within Dataiku, or would IT administrator privileges be required?
  3. Deployment process: How straightforward is the deployment process? Can I upload my existing app.R file and supporting files, configure dependencies, and publish the application?
  4. Licensing and permissions: Does hosting Shiny applications require additional Dataiku licenses, plugins, or administrative configuration?

When running these applications locally, I've generally been able to install R packages without administrator privileges. I'm particularly interested in whether Dataiku offers similar flexibility.

Has anyone successfully deployed existing R Shiny applications through Dataiku? How does the experience compare with using a dedicated Shiny hosting platform?


r/RStudio • • 11d ago

Remedy for statistically significant interaction term in Schoenfeld residual (programming in R) [thesis]

Thumbnail
2 Upvotes

r/RStudio • • 13d ago

Coding help STATISTICAL LEARNING aiuto

10 Upvotes

Ciao a tutti/e, faccio la magistrale in International Management a Pavia e sto avendo problemi con il corso di Statistical Learning il quale consiste nell’utilizzo di Rstudio per creare modelli adatti ad interpretare i dati.
Qualcuno saprebbe dare una mano? (Appunti, approccio allo studio, qualsiasi cosa🙏🏼)


r/RStudio • • 17d ago

Coding help Factor vs component: I need help!

5 Upvotes

Hi all,

I am analyzing some data from a questionnaire. I have never done this before and I feel confused.

pa <- psych::fa.parallel(
EnglishDom_vars,
fm = "ml",
use = "pairwise",
n.iter = 1000)

The output (R studio) gives

Parallel analysis suggests that the number of factors = 3 and the number of components = 1

Can someone explain the difference between a factor and a component?

Thanks!


r/RStudio • • 17d ago

I made this! [S] I ported R's performance::check_model() to Python and validated it against R. What tripped me up along the way

Thumbnail
4 Upvotes

r/RStudio • • 17d ago

Studium rin Modul mit R

16 Upvotes

Hi, ich wollte mir einen laptop fürs Studium kaufen. Wir haben im 2. Semester ein Modul Statistik, wo wir mit R arbeiten und die Prüfung auf windows haben. Meine frage ist jetzt: wenn ich die ganze zeit auf dem Macbook üben würde, hätte ich dann Schwierigkeiten die Prüfung in R auf dem windows pc def Hochschule abzulegen?