Visit the CRAN website and download the version for your operating system.
There are three options, but the instructions below focus on Windows:
Visit the Posit website to download RStudio for your platform.
Note: R can function without RStudio, but RStudio requires R to run.
If you use a Mac, refer to the following guide for installing R and RStudio:
Open RStudio and check the “Console” (typically in the bottom-left panel unless you have changed the layout) to see the current version of R installed.
.exe
file).RMarkdown allows you to create documents (PDF, HTML, Word, or slides) that integrate code and text. It is useful for reproducible research and teaching with dynamic content.
This section provides a basic example of an RMarkdown file. You can write text, include R code, and generate output dynamically.
## Warning: package 'ggplot2' was built under R version 4.3.3
# Generate random data
data <- data.frame(x = rnorm(100), y = rnorm(100))
# Scatter plot using ggplot2
ggplot(data, aes(x = x, y = y)) +
geom_point() +
theme_minimal()
The value of x
computed earlier is 8.
Click the Knit button in RStudio to generate an HTML, PDF, or Word document.