R practice
Practice R online: 10 exercises, graded problems and a playground
The R here is the genuine R interpreter, compiled to WebAssembly by the webR project, so vectors, c(), for loops over 1:n and cat() behave exactly as they do in RStudio's console. The exercises are built around cat() rather than print() so your output is plain text you can check, and each one puts its data directly in the code — this runtime does not read keyboard input yet.
- checked exercises
- 10
- graded problems
- 0
- lessons
- 0
- cheat sheet (coming)
- 0
R practice exercises
How the path works →In order, each one introducing a single new idea. Press Run to check your answer; hints open one at a time.
- Say Hello with cat()Printing text with cat()
- Greet a Learner by NameAssigning values with <-
- Add Up Two PricesArithmetic operators (+, -, *, /)
- Check the Temperatureif / else branching
- Format an Order LineBuilding formatted strings with paste0()
- Count from One to Fivefor loops over a numeric range (1:n)
- Read Values from a VectorVectors with c() and 1-based indexing
- Loop Over a Price ListLooping over a vector with length()
- Total the DonationsAccumulating a running total in a loop
- Build a Grade ReportCombining loops, conditionals, a vector, and formatted output in one program
Coding interview questions
Original questions with full model answers, for when the practice is going somewhere specific.
Questions people ask
- Is this real R?
- Yes — the R interpreter itself, via webR, running in your browser tab. Base R is fully available; CRAN packages that need compilation or a network are not.
- Why do the exercises use cat() instead of print()?
- print() adds an index like [1] and quotes around strings, which is useful at a console and confusing when an exercise checks exact output. cat() prints only what you give it, so the exercises use it and explain sep and the newline you have to add yourself.
- Can my program read input?
- Not on this site yet: the R runtime does not read standard input, so readline() and scan() are not part of the exercises. Every value a program needs is in the code.
- What is here after the beginner exercises?
- After the 10 exercises: the SQL path, which pairs naturally with R for anyone heading into data work.
Practise another language
The same kind of practice hub exists for Python, JavaScript, TypeScript, Java, C++, C, C#, Go, PHP, Ruby, SQL and Bash & the Shell.