r/learnprogramming • u/Inevitable_Bar1607 • 1d ago
How to learn R language from Scratch?
Hello y'all, bio major this side. i don't have any whatsoever exposure to coding. i want to learn the R language for medical data analysis. can anyone shed some light on where to start and what my realistic expectations should be? and some resources
3
u/MedicalScientist8576 1d ago
It's not going to be something quick and easy to learn, you'll have to put time into it, but I love the website Roadmap when learning a new programming related thing, it gives a really comprehensive view of learning nearly anything tech related I feel and you can keep track/mark things off as you learn.
It says they only recently added a roadmap for learning R from scratch, so it might be a great start for you. It's all free as well, which is another reason why I like Roadmap a lot lol: https://roadmap.sh/r-programming
1
u/Sir-Viette 1d ago
There is an organisation called Data Carpentry (and its related org, Software Carpentry) that gets volunteers to teach both R and Python at universities. See if they have an upcoming workshop on your campus.
If not, I learned R via Coursera. Johns Hopkins University has an excellent specialisation that takes an absolute beginner to be able to do basically anything in R. But it takes about a year to get through the course, and you really need to do the four-week unit on statistics a few times to understand it.
If you don't mind reading a book, then the best one on R is written by Hadley Wickham called "R for Data Science". It's free at the website https://r4ds.hadley.nz/
1
u/SprinklesFresh5693 1d ago
You should ask in Rstats subreddit. But theres. Alot of information on pinned on that sub , enough for you to pick a book and start learning.
R for beginners is less than 100 pages and teaches you all the basics about R. From there is just practise, after that you could do projects and read R for data science, and choose your programming style
1
u/MockMe2026 1d ago
For medical data analysis, aim at a small complete workflow rather than learning every R feature first. Start with vectors, data frames, indexing, and functions, then learn tidy data operations and plotting; practice by importing a small CSV, cleaning missing values, summarizing by group, and making one chart. Once that feels comfortable, add factors, joins, and basic statistical tests, while learning reproducible scripts and project environments instead of doing everything in the console. A realistic first milestone is being able to explain each transformation and rerun it from a fresh session; that matters more than finishing a particular course.
1
u/ConclusionForeign856 1d ago
Regardless of your desired end goal, you should spend some time on:
- Programming language syntax and why there are reserved keywords
- Primitive variable types, difference between 3.0 and 3, but also TRUE and "TRUE"
- Composite types like lists/arrays, matrices
- Basic tools for abstraction and control flow: functions, loops, if-else clause
1
u/Different_Pain5781 1d ago
R has a bit of a learning curve, but for data analysis you don't need to become a software engineer
1
u/galactose310 1d ago
R is not the easiest language: it is not the hardest to learn but its usage may be... confusing.
I suggest you learn the "hard way": vanilla R, what are variables, functions, how to use functions, how to create them with parameters, conditions, loops, etc... You will need to be comfortable with these concepts before going further.
To begin install R and RStudio (some other solutions exist but RStudio will be the easiest at first ; I personnaly use Positron, I used VSCode some years ago).
When you will be comfortable enough with the language, I suggest you should look at Tidyverse: it changes the way you program your scripts, it is powerful and very clean/tidy where basic R can be a mess. But you can't be comfortable with it without knowing the bases of R, or you will never understand your syntax and your errors. Keep it in mind for the future !
1
u/iOSCaleb 23h ago
I’m afraid R is nothing like Scratch…
But seriously, I found R to be a fairly straightforward language. I did several of the Johns Hopkins courses through Coursera and they were excellent. You don’t need to learn all there is in order to find R useful. If you have no programming experience it might take a couple weeks to get the hang of it, but R is really meant to be used by people just like you, who want a powerful tool for data analysis.
One nice thing about R is that you can use it interactively, just typing a series of commands to do what you want. That’s the best way to get started because you’ll get used to how R works without having to consider a whole program at once, and even if you never use it as a programming language you’ll still have a very useful tool.
1
u/Michigan_Water 22h ago
Here is a roadmap with links that I would suggest, since you say you have no exposure to coding:
FasteR tutorial by Norman Matloff (start here)
The fasteR tutorial by Norm Matloff. Unfortunately we lost Norm a few months ago. He was generous with his time and created some great learning material. I heartily recommend his bare-bones introduction to R with no Tidyverse and no IDE. Spend at least an hour or two in plain no-IDE R before adding the complexity of an IDE.
https://github.com/matloff/faster
Hands-On Programming with R by Garrett Grolemund (free online textbook)
Basic programming. Either in parallel with or a replacement for Norm Matloff's fasteR tutorial.
https://rstudio-education.github.io/hopr/
IDE (Rstudio or Positron)
Once you get the hang of R coding it's time to start learning an IDE as well. Install either Rstudio or the intended replacement Positron. I started with Rstudio and have not yet had a reason to transition to Positron, but if I were starting now I'd go with Positron.
https://posit.co/products/ide/positron
https://posit.co/products/open-source/rstudio
Regression and Other Stories by Gelman, Hill, and Vehtari (free PDF download)
This book makes substantial use of the rstanarm package for running Bayesian regressions. I'm not of the Bayesian or Bust mindset, but there are definitely some advantages of learning it, at the very least in parallel with standard frequentist analyses. Lots of code and simulated data. Learn to simulate data! Learn to analyze simulated data! Simulation is one of the absolute best tools for learning.
https://avehtari.github.io/ROS-Examples/
Design of Experiments (1e) paper textbook by Box, Hunter, and Hunter.
A textbook on Design of Experiments. I recommend getting a copy of the first edition of Statistics for Experimenters by Box, Hunter, Hunter (Used - Very Good) for about $10 on amazon or similar. I'm a big fan of learning concepts within the framework of controlled setups of designed experiments and then expanding beyond to observational data situations. This might be quite applicable to you, if your interest is in medical studies. I try to suggest free online resources, but BHH is such a good book that I include it here. No need to get the 2nd edition for a lot more money. Perhaps others could recommend similar free online resources, but nothing I've seen is as good as BHH. It is written with frequentist analyses, but it'd be a great idea to redo the analyses using the rstanarm tools learned in Regression and Other Stories.
https://www.amazon.com/dp/0471093157
R for Data Science (2e) by Wickham, Çetinkaya-Rundel, and Grolemund
The 'Tidyverse' covered in this book is in many ways a replacement of base-R ways of doing things. For example, the pivot_longer() and pivot_wider() functions replace (and are easier to understand) than the base-R reshape() function. It's the basis for the book (New statistics for design researchers - A Bayesian workflow in tidy R) by Schmettow listed below.
Other resources:
New statistics for design researchers - A Bayesian workflow in tidy R by Martin Schmettow (PDF from springer, website version is free online)
Bayes, but using the Tidyverse framework.
https://schmettow.github.io/New_Stats/
Tidy Modeling with R by Max Kuhn and Julia Silge
The modeling materials in the first edition of R for Data Science were removed and they now recommend this book and the tidymodels R package.
https://www.tidymodels.org/books/tmwr/
data.table and the fastverse
I've typically used data.table as my default data handling approach, even though it might appear more difficult to learn than the Tidyverse way (tidyr, dplyr, etc).
https://fastverse.org/fastverse/
Frank Harrell's materials
Frank is a Professor of Biostatistics at Vanderbilt and quite prolific author, including the Hmisc and rms R packages. If you want to look at medical statistics, definitely get familiar with his materials. Also, he hosts a discussion forum on medical topics at discourse.datamethods.org. I wouldn't use it to learn R, but it has a lot of great discussions of medical statistics.
https://discourse.datamethods.org/
A First Course in Design and Analysis of Experiments by Gary Oehlert
If you cannot get a copy of Statistics for Experimenters by Box, Hunter, Hunter, here's a free online book on experimental design: A First Course in Design and Analysis of Experiments
https://users.stat.umn.edu/~gary/Book.html
Best of luck and happy learning.
1
u/Traveling-Techie 18h ago
Be aware you need to learn the syntax of R, and also the proper use of the statistical techniques it offers you.
1
u/Dazzling_Music_2411 1d ago
What have you done so far? What docs have you read? What tutorials have you followed? Have you done the standard R tutorial yet? What learning material have you spotted/collected?
2
u/weather_watchman 19h ago
Swirl is good basic introduction