Syntax

R Create a Data Frame Syntax

In R, create a data frame: creates a table of columns — df <- data.frame(x = 1:3, y = c("a", "b", "c"))

Quick Answer

Syntax
df <- data.frame(x = 1:3, y = c("a", "b", "c"))
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

How to create a data frame in R

  1. Open your R file or editor.
  2. Copy the example, then replace its sample names and values for your code.

R Create a Data Frame Syntax

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

Related Syntax References

Frequently asked questions

What is the R syntax for create a data frame?

Use this pattern: df <- data.frame(x = 1:3, y = c("a", "b", "c"))

Can I copy this R code example?

Yes. Use Copy code and adapt the example to your program.

Is this R syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify