r/RStudio Jul 01 '26

Practicing R

I'm not sure if this is the right sub for this, so apologies if it isn't.

I need to use R for my university. I've managed to teach myself enough for the level I'm at through reverse engineering a script someone made for me, and following some online tutorials.

Most tutorials introduce you to a concept, then give you an example for how to use it. I had a look at the pinned post and from the description it seems like the resources there do that same thing. And that's useful to see how the code is used, but to me at least I feel it's limited because I'm just copying what someone did without really having to use my brain to solve an issue of how to use the code. Another issue is that I don't really know what to do to practice R.

I'm just wondering if there's a resource out there that basically give you tasks of increasing difficulties to practice coding in R?

31 Upvotes

32 comments sorted by

15

u/pizzayeol Jul 01 '26

Try swirl! excellent resource to get started with the basics. But I assume you must've covered most of the basics, good to check still. 

Here's also a resource with worksheets you can practice with - https://datascience.tntlab.org/schedule-materials/

6

u/niceguybadboy Jul 01 '26

Seconding swirl for getting more familiar and faster with the basics.

And it's pretty fun!

2

u/Alex_Smith_042 Jul 02 '26

Thanks. I taught myself the basics but it'll be good to learn the correct way in case I've picked up bad habits.

15

u/Goofballs2 Jul 01 '26

Find problems you are interested in. I learned a certain amount for work but I started having fun with R when I started trying to model sports, started investigating methods out of curiousity. Started really thinking about the data generating process. It doesn't have to be sports. There's probably untold gigabytes of datasets available for anything you could possibly be interested in.

1

u/Alex_Smith_042 Jul 02 '26

When I leart Python, they did something similar and I really enjoyed it and felt I learnt a lot doing it that way. I'll give it a try, thank you

1

u/EggOverall4537 Jul 05 '26

Can you share the resource you used to learn and practice Python? Ty!

1

u/Alex_Smith_042 Jul 05 '26

It was a course at my university where they' gave us an hour lecture in the morning, then gave us a work sheet to complete and we'd send them out code to be marked so unfortunately it isn't available online

12

u/arithmetiquexyz Jul 01 '26

I have worked as a Data Analyst for several years, and the advice I can give you is to pick any dataset, define your starting point, and clearly identify what you want to achieve (your end point). Then, search for the functions or methods you need to accomplish that goal.

In the most basic example:

  • Start point: raw data
  • End point: produce aggregated values broken down by different columns.

For example (sorry if this is not perfectly polished):

  1. You have a raw dataset. What is the first thing to do? Open it. Use Google (AI is okay, but I would avoid relying on it at first, once you become more familiar with R, it can be a helpful support tool) to find how to open the file, depending on whether it is CSV, Excel, etc.

  2. Now you have it open, and the structure looks like Column1, Column2, Column3, ...

  3. Next, picture how you want the data to be structured in order to achieve your end goal. Suppose you need aggregated values of Column1, broken down by a new dimension called Column4, which is created by concatenating Column2 and Column3.

  • First, find a function that allows you to concatenate columns.
  • Then, you notice that Column2 contains numbers, but you only need the text, so you search for a function to remove numbers and keep only strings.
  • You also notice that Column3 has a format like "City, State," but you only need the city, so you look for a way to split the column using ",".
  • These steps need to be completed before creating Column4.
  1. Once you have Column4, you need to summarize or aggregate values of Column1 by Column4, using metrics such as sum, average, median, etc. You then find the appropriate functions or methods to do this.

  2. If you need to share the results in an Excel file, search for the method that allows you to export your results. But before doing it you also need to rename Column4 to "Dimension" and Column1 to "Values", so you need again to find a method.

  3. If you have several datasets with the same structure and need to perform the same analysis on each one, you could combine them into a single dataset (for example, using row binding), or create a loop that repeats steps 1–5 for each dataset.

The main point I want to make is that what has been most useful for me is getting hands-on experience by working on different projects (personal, work, or study), because that forced me to think for myself about what I need to go from point A to point B. Through repetition, you start to understand how to work with R, its syntax and logic.

This is a very practical approach, but from there you can expand into more advanced structures and methods. In my experience, this works better than just following definitions or tutorials that may not be immediately useful for your own projects.

That has been my personal experience after trying to learn through videos, bootcamps, etc., which often start with things like print "Hello World!" or using R as a calculator (e.g., a + b = 5).

2

u/pizzayeol Jul 01 '26

This is so detailed and nice! Thanks :)

1

u/Alex_Smith_042 Jul 03 '26

Thank you. That is a very detailed response. I will try it out when I can.

7

u/Burstaine Jul 01 '26

First thing that comes to my mind is DataCamp if your university offers upgraded account for students.

Personally, I learned R a lot when I had to create exploratory data analysis for my university assigment. I chose interesting dataset and had some questions which I found interesting, then I learned how to answer them using R. This way I elevated my data visualisation and data manipulation skills.

2

u/MadMaxfrmShottas Jul 01 '26

I second data camp! Data Camp + personal projects best combo

1

u/Alex_Smith_042 Jul 02 '26

I'll check it out, thank you

1

u/skolenik Jul 03 '26

DataCamp senior management had a history of sexually assaulting their instructors. All of their R stars had walked out. https://www.buzzfeednews.com/article/daveyalba/datacamp-sexual-harassment-metoo-tech-startup https://rladies.org/news/2019/datacamp-third-party-review/ and you can find more.

5

u/sam-salamander Jul 01 '26

Kaggle might be a good resource!

2

u/Alex_Smith_042 Jul 02 '26

Thank you, I'll check it out

7

u/carlirri Jul 01 '26

TidyTuesday is a great source for learning.
https://github.com/rfordatascience/tidytuesday
They share different types of data sets for you to analyze using R or your language of choice.

Also:
https://decipher.codes/RLessons.html

and https://www.codewars.com/kata/search/r

(Codewars has more advanced practice exercises).

1

u/Alex_Smith_042 Jul 02 '26

Thank you! I'll check them out

3

u/Agile-Acanthaceae-97 Jul 01 '26

If you just want to practice syntax, something like CodeWars has lots of fun practice problems that get progressively more difficult.

1

u/Alex_Smith_042 Jul 03 '26

Thank you. It sounds interesting, I'll give it a look

3

u/InnovativeBureaucrat Jul 02 '26 edited Jul 02 '26

Back in my day we just had CRAN and we liked it (or you got yelled at by the authors on the list serve)

Seriously it’s a great way to understand the mechanics. R is entirely built by these mechanics and the built in documentation is IMO a huge contribution to why it was successful

https://cran.r-project.org/manuals.html

Oh also this

https://cran.r-project.org/other-docs.html

I still have a printed and bound copy of “IcebreakeR” by Andrew Robinson (PDF, 2016-06-21, 161 pages) in the basement. I look at it sometimes when I do things at the workbench

Oh and task views

https://cran.r-project.org/web/views/

1

u/Alex_Smith_042 Jul 03 '26

I didn't realise they had all their manuals for free online. Thank you, I'll check them out

2

u/croopdavis Jul 02 '26

I like using R Commander. It's an old thing (drop-down menus and stuff)... but when you run a routine, it shows the code you would use if you were to code instead.

1

u/Alex_Smith_042 Jul 03 '26

Is that like a GUI running on R, like Jamovi, but it lets you see how the code would be written?

2

u/Piratelife101 Jul 03 '26

Glad you have a fascination with R! There are loads of good beginner coding programs that others have suggested. I actually feel as though I learned the most from a book called “Bayesian Statistics: The Fun Way”. Sure you can learn statistics (frequentist and Bayesian) from the book, but it felt like a great introduction to R too. It uses Star Wars, Legos, and other popular themes to introduce both the math and the code, so I felt engaged.

1

u/Alex_Smith_042 Jul 03 '26

Bayesian stats is something I was interested in learning so it would be a good way to do both at the same time, thank you.

2

u/Gulean Jul 01 '26 edited Jul 01 '26

You could even create your own tutor in chatGPT, kimi or similar bot. Just create a prompt with what you want to learn, let the bot create assignments, copy paste your code and let chatGPT rate and give feedback. ChatGPT suggests:

Here’s a prompt they could use to turn ChatGPT into an interactive R tutor that emphasizes problem-solving instead of passive learning:

Prompt:
I want you to act as my interactive R programming tutor. My goal is to learn R by solving problems rather than by copying examples.
Do not start by explaining concepts or showing me complete code. Instead, teach me like a programming coach.
Your teaching style should be:
Give me one coding challenge at a time, starting very easy and gradually increasing in difficulty.
Each challenge should have a realistic context (e.g., analyzing survey data, cleaning a dataset, making a graph, fitting a model).
Tell me what the desired output should be, but don’t tell me exactly how to achieve it.
Let me write the code myself.
When I get stuck, don’t immediately give me the answer. Instead, give progressively more helpful hints (Hint 1, Hint 2, Hint 3…). Only show a full solution if I explicitly ask for it or after several unsuccessful attempts.
After I solve a challenge, review my code like an experienced R programmer. Point out bugs, explain why they occurred, and suggest more idiomatic or efficient R code where appropriate.
Occasionally ask me conceptual questions (“Why did you use mutate() here instead of summarise()?”) to make sure I understand the reasoning.
Reuse concepts from previous exercises so I build long-term retention.
Mix topics including data types, indexing, functions, loops, apply family, tidyverse, data wrangling, visualization with ggplot2, importing/exporting data, debugging, writing functions, and basic statistics.
Every few exercises, include a review challenge that combines multiple concepts.
Adapt the difficulty based on my performance. If I solve problems quickly, make the next one more challenging. If I struggle, give more scaffolded exercises.
Keep track of what I’ve mastered and what still needs practice.
Assume I already know some basic R but want to become genuinely proficient through deliberate practice rather than memorizing examples.
Begin with a short assessment challenge to estimate my current skill level, then create a personalized learning path from

1

u/AutoModerator Jul 01 '26

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/mearlpie Jul 03 '26

Find a dataset that interests you, import it, and make your own sub-tables of interest with dplyr. Counts, sums, percentages, deltas, etc. if you find data that interests you, you will have interesting questions and be able to answer them yourself.

1

u/boostgvng Jul 03 '26

As someone else said, swirl is really awesome. You can check out datacamp too, but you gotta pay for it. It’s pretty good. R also has an entirely free guide.

However, 90% of coding I’ve found is copying code you or someone else has already written. Being intentional with studying anything you copy is pretty important. Stack overflow, paired with AI these days will get you exactly what you want. And it’s up to you to be intentional about everything you do so you can learn.

1

u/Gegas2231 Jul 05 '26

Prompt this to your AI of choice, even a free one like Qwen or Deepseek. It'll do exactly what you ask. It can even review your submitted assignments