R Syntax References

R syntax quick reference: vectors, data frames, CSV files, statistics and packages, from An Introduction to R. Every item below is clearly marked as a shortcut, command, or syntax reference.

Most Useful R Syntax References

RSyntax

Assign a Value

Code example
x <- 5

Assigns a value to a variable.

Learn More
RSyntax

Create a Vector

Code example
v <- c(1, 2, 3)

Combines values into a vector.

Learn More
RSyntax

Create a Data Frame

Code example
df <- data.frame(x = 1:3, y = c("a", "b", "c"))

Creates a table of columns.

Learn More
RSyntax

Read a CSV File

Code example
df <- read.csv("data.csv")

Loads a CSV into a data frame.

Learn More
RSyntax

Print a Value

Code example
print(x)

Prints a value.

Learn More
RSyntax

Select a Column

Code example
df$x

Gets a column from a data frame.

Learn More
RSyntax

Filter Rows

Code example
df[df$x > 1, ] subset(df, x > 1)

Keeps rows matching a condition.

Learn More
RSyntax

Summary Statistics

Code example
summary(df)

Summarizes each column.

Learn More

More R Syntax References

Frequently Asked Questions

What does this R syntax reference cover?

It covers 20 common R patterns and examples, including Assign a Value, Create a Vector, Create a Data Frame, Read a CSV File, Print a Value.

Can I copy the R examples?

Yes. Each reference page includes a copyable code example.

What affects these R examples?

Check the linked documentation for language or runtime version requirements. Libraries, file paths, terminal quoting and environment settings can differ across systems; no blanket platform compatibility is implied.