R Program to Sample from a Population
Draws a random sample without replacement.
[1] 3 4 10 6 2
Generate random values from normal, uniform, and Poisson distributions; sample from populations. Useful for simulation and experimentation.
Draws a random sample without replacement.
[1] 3 4 10 6 2
Generates random values from Normal, Uniform, and Poisson distributions.
rnorm: 1.371, -0.564, 0.363, -0.106, 1.513 runif: 0.914, 0.940, 0.288 rpois: 2, 1, 2
Concatenates strings using paste0.
[1] "Hello World"
main.R, then run Rscript main.R from your terminal. Alternatively, use an IDE such as RStudio.
R is a powerful language for data analysis, visualization, and statistical computing. Practicing small, focused programs builds fluency with vectors, data frames, lists, functions, control flow, and string manipulation.
On this page, you’ll find clean, well-formatted examples that run across platforms. Each example includes a short description and expected output so you can quickly verify your understanding. Explore the topics via the sidebar and extend the code to experiment further.
Whether you’re preparing for coursework, handling data tasks at work, or learning R for research, these examples offer a practical path to mastery. Bookmark the page and revisit to keep sharpening your skills.