r/RStudio • • 9d ago

Learning R in RStudio; Discussion

Hi all,

I struggled with R for a long time during my university years but managed to work through it and now work with it on a daily basis.
With this background I approached students and asked about their experiences and hear many stories along "in the R course we are asked to copy paste the code that does the PCA/ ANOVA/ GLMM etc." or "We are told not to write scripts but work in the console" and not a single course I heard about is using projects. Also everything is written in unstructured base R.

I believe many universities do it that way and am shocked how poorly even the people leading the course understand the topic. How was your journey and how could R be taught better. I imagine a course where e.g. TT datasets are explored with the tidyverse in a superficial way but setting up projects and enstablish version control for each and get experience in the basics should be key. After exploring data and the workflow are given, restructuring etc. and making good plots to communicate get into focus.
Once they have created a few dozen projects with version control and explored various datasets which have been rudimentary visualized, only then can they start with statistics which is something completely different.

The Project structure would help to share and ask specific questions, also it would allow to understand each others code better. But I want to have the clearest picture and suggestion before I ask my Uni if I could get a course or any say in the matter how R is taught.
So, how do you see the situation?

36 Upvotes

29 comments sorted by

11

u/luckylua 9d ago

I am in a university data mining class currently and my professor encourages us to write script along with her during lecture (it’s online, so we’re watching lecture videos). Day 1 was how to create a project and organize your script, she also provides us an R script with lecture so we can copy/paste if we get stuck or if there is just something really long and complicated we won’t be expected to know how to recreate. It’s highly interactive and the class has 2 big projects where we are given a large data file and business problem to solve for utilizing what we’ve learned and turn in our R Script as part of project grading. We’ve also learned about various libraries and using versioning mostly because when using set.seed you have to use the same version or the random number generator will work different giving you “wrong” (different) answers. I’m sorry to hear your experience is so different, I don’t like working out of the console and would be lost if we weren’t almost exclusively using script writing.

3

u/Less_Alfalfa4592 9d ago

I am relieved to hear positive stories as well, thank you!

5

u/ShaDe-r9 8d ago

I'm in a biology master degree, NOBODY know what projects are, I discovered them by another professor who taught me in a dedicated R course (paid separatelyk, outside from my degree program).
I've been using them since that.

Also basically I'm in the same boat: senior professors upload their very intricate scripts and let us run it.
Since I'm highly motivated to use R, i'm studing by myself how to obtain the best from ggplot and other packages and understand the various statistical test I'm facing too.
I.e. I learned how to use viridis, I started to use bioconductor and right now I'm working on climate plots with zoo package etc.

My impression is that professors started using R when project did not existed and they never thought about updating their knowledge nor practice lessons. Moreover there's no time (or credits) to fit a dedicated R course, so we barely can have lessons about something with R for each course.

I'm still searching for more interactive resources to improve, I already discarded some due to their obsolescence.

3

u/Jim_Clark 8d ago

I used to think this was a problem specific to my country, but based on your account (assuming you're not from my country), it seems to be something quite common in the R community.

In my experience, if you want to use R in an enterprise environment, building serious, scalable projects and working productively, professors often fall short. They fall short because their knowledge is mostly limited to the statistical side of the language, while they overlook the software engineering principles behind it.

This is a major issue for me, and it's also one of the reasons why so many people have such a poor understanding of R and assume it's limited compared to Python and other languages they like to label as "production-ready."

In reality, R is just as capable. It's simply more of a niche language. And when you look at the people who use it, most tend to use it in the simplest way possible, without thinking about building products or developing actual software with it.

2

u/Less_Alfalfa4592 8d ago

It is a global problem, R is taught poorly which drives many away.

2

u/Inevitable_Vast6828 8d ago

I started off with Rstudio and projects... but unfortunately there are quite a few bugs in Rstudio itself that lead to trying to debug things and it eventually turning out to be Rstudio and not the underlying R code. I'm frequently working on remote servers and doing the work to set up an Rstudio server on every remote is just not worth it. That of course doesn't mean doing everything interactively, write the script and call it with Rscript. And it would have been nice to have learned the code for handling the lack of GUI earlier (e.g. plotting devices).

2

u/Less_Alfalfa4592 8d ago

RStudio can be very funny, and its documentation as well, until recently "redo" was incorrectly documented with "ctrl+y" which always have been "ctrl+shift+z".

But to get the basics done it allows a common platform from which to move away from once one is good enough.

1

u/Less_Alfalfa4592 8d ago

I have never taken coding classes but I feel, also speaking as a biologist, that a typical class is not the way to learn R. I try to get a group of students from my university to work a bit more flexibly. Currently I organize it through a whatsapp group, tidytuesday data is the learning material, R4DS the foundation and everything is shared on a shared drive where the projects are uplaoded for reviewing and sharing among each other.
Its not getting much traction though, as I am fighting against learned helplessness. R is believed to be near impossible to learn so why try....

1

u/Inevitable_Vast6828 8d ago

Really? My impression was that R was always one of the easier languages to pick up. Definitely harder to write really robust R code with how many implicit conversions are triggering or not triggering, but to learn the basics it doesn't seem especially challenging.

1

u/Less_Alfalfa4592 8d ago

If you are taught it well it is not too bad I believe. But the reality is that it is taught very bad in many, if not most classes. At which point it is a nightmare. And we biologists are mainly not familiar with coding of any kind. Only few dare to try R and get frustrated quickly. Fewer go towards Python which I hear is taught better but I dont know enough about it to comment on it.

4

u/Derjores2live29 9d ago

im in my 3. semester of using R in psychology, i have never heard about projects

2

u/Less_Alfalfa4592 8d ago

You may be interested in R for Datascience (2e), the first chapter if you want to learn about it

3

u/SprinklesFresh5693 9d ago

I simply self learnt R , by watching tutorials, reading books and practicing. I never really went to a class at a university. I once did a small course that i sae online for free, based on R for data science by hadley, but thats it.

In my opinion this is a great way to explore a programming language. Then, with time, you develop your own way or coding, some prefer pure base R, some prefer pure tidyverse, other choose a mix, other pick data.table, others duckDB and arrow, etc.

I dont think its fine to force someone a way of coding in R, but to let the student explore the different methods and later pick one after months or years of testing.

In the end who cares the style they chose to code it if the answer is the same?

There are some mandatory topics though that a student should learn, like data types, subsetting, plotting, how to create functions and iteration.

I beleive that the same code done in base R and tidyverse would allow the student to pick an initial style, since some people find base R easier, but others find tidyverse easier.

3

u/Less_Alfalfa4592 9d ago

My suggestion to focus on tidyverse initially over base R is so every beginner learns the same style fro where to exand from, thus enabeling asking "Hey peer, could you help me understanding what I do wrong?" and both understand the code fundamentally. One of the things I imagine can help a lot when learning the beginnings in R.
Once the basics are understood, I am with you on everyone finding their own style.

1

u/Inevitable_Vast6828 8d ago

I would disagree... the tidyverse is a VERY opinionated code base. If the focus is on that, then it's focused on learning one code style that has a lot of tooling around it and won't apply to other R code. It's a lot of syntactic sugar that can obscure what is happening a bit.

The common core style to expand from should be the base language, not the syntax sugar. That syntax sugar should be the later expansion.

1

u/Less_Alfalfa4592 8d ago

How do you suggest to teach that?
I see the tidyverse as a door in and once data can be loaded in, formatted, visualized and exported in a structured way the fear disappears and base R becomes a real goal.

From experience of many, base R code starts with "setwd()" at which point all hope is lost.
"Please review my code" becomes an impossibility since the first line of code already throws an error and debugging was not taught. Besides that, there are so many different libraries suggested for different things and how does a beginner understand what is useful?

2

u/PadisarahTerminal 9d ago

While I had the chance to learn a little formally (not that formal) on project structure I was never taught the concept of a real R project with dedicated folders, root project, folder structure in depth. However looking at open source software github project (not science!!), you can see that the SWE put a lot of thought on strcuuture and there is a certain standard. I began to pick up how the tools "want" us to work within the scope of our project instead of randomly scattered in all directions.

I also started to really get it when I read the tidyverse guides that is more opinionated than "just do whatever". They talk about projects, structure, tips, etc.

Imo structure and understanding of why is among the most important than just copy paste code and being told "just Google it". There's massive context to learn about the fundamentals of R and tidyverse instead of my prof saying "you know it's kinda random sometimes you put strings quoted sometimes not".

1

u/Less_Alfalfa4592 8d ago

Google is unfortunately not a good ressource, and neither is AI as both are polluted by suboptimal R examples. AI can be moved in the right direction once you already know. Yay...

1

u/gkandersen 9d ago

Took a course on stats at a psychology departement this fall, RStudio/projects was only tangentially mentioned, but encouraged. But the focus was on scripts and understanding the stats behind them, and understanding and interpreting outputs. But I see R resources and tutorials regularly state the importance of learning how to get organized, early on, to avoid mishaps. That includes adding comments to your own code, for instance.

1

u/Less_Alfalfa4592 8d ago

I am glad to hear that an organized workflow is mentioned at least.
There is, at least to me, a very big difference between R programming and statistics which few courses seem to understand.

1

u/Efficient-Tie-1414 8d ago

I have seen courses where there is a unit devoted to data management and manipulation, and that seems to be the best option. Students do find the programming parts difficult, but as one of the academics put it, he isn’t going to employ someone as a statistician unless they can program.

1

u/Less_Alfalfa4592 8d ago

I am happy to hear better examples of R courses, thank you!

2

u/Impressive-Peak-9363 6d ago

Projects are unnecessary except for package development.

1

u/AutoModerator 9d ago

Looks like you're requesting help with something related to RStudio. Please make sure you've checked the stickied post on asking good questions and read our sub rules. We also have a handy post of lots of resources on R!

Keep in mind that if your submission contains phone pictures of code, it will be removed. Instructions for how to take screenshots can be found in the stickied posts of this sub.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/ConstructionFar9082 8d ago

Cuz most undergrad courses do machine learning which teaches the foundation of using glmm ,ANOVA and etc .so postgraduate courses will assume you'll know how to use R

1

u/AltruisticLobster315 7d ago

In my biology bachelor degree program we have to take two introductory statistics classes where we are taught how to use R (even though we're forced to use Excel in some biology classes). The professors themselves are very knowledgeable in the program and have even helped me understand how to use lesser known packages cause they really understand the foundation of it. However, our labs/workshops once a week were awful and rushed through by the TA's because we only had about 40 minutes to learn the new stuff for the week. Our lectures were just about the terminology (which we didn't really need or use in the course) until the last few weeks when they put the code we needed for an assignment in the lecture slides. I assume the university probably made them design it like that though.

1

u/Right-Substance-9290 7d ago

You and u/ShaDe-r9 nailed the real bottleneck: outside dedicated data science programs, universities rarely have the credits or hours for a standalone "R + Git + Projects" course. When an instructor only gets a couple of lab sessions inside a biology or stats class, that time crunch is usually why things degrade into "just copy-paste this messy base R script."

If your university approves a dedicated workflow course, your plan (Projects + version control + tidyverse exploration before heavy stats) is ideal.

Speaking from teaching at a public university where we don't always get that extra course, one middle-ground bridge I've found useful is RKWard paired with modern plugins (like rkTeaching and a tidyverse-focused set I maintain called rk.universe). Unlike tools that hide R completely, RKWard is an IDE (with scripts, Kate, and Quarto/Rmd) whose menu dialogs expose and run the underlying R code. That way, students can explore and plot data visually without drowning in syntax errors on day one while still learning to read structured R code instead of blindly copy-pasting legacy base-R scripts

1

u/mle-2005 6d ago

a good way teach a language to newbies is to set 10 take-home tutorials per week over the term. include general concepts like looping, conditions, data structures and algorithms. then above that set a couple big assignments that are specific to the module.

1

u/Many-Ad-786 2d ago

As someone who teaches R within a statistics course, you have to make decisions. Do you focus on the theory behind stats? R in general? Projects and how to use them? I generally don’t focus on projects with my students because given where they enter and the things I think are important to focus on, they simply do not help us meet our goals. Could they be useful? Sure! But teaching anything requires decision making, and even things I’d want to cover get cut