Syntax

R Filter Rows Syntax

In R, filter rows: keeps rows matching a condition — df[df$x > 1, ] subset(df, x > 1)

Quick Answer

Syntax
df[df$x > 1, ] subset(df, x > 1)
RSyntax

Filter Rows

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

Keeps rows matching a condition.

Learn More

How to filter rows in R

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

R Filter Rows Syntax

Use df[df$x > 1, ] subset(df, x > 1).

Related Syntax References

Frequently asked questions

What is the R syntax for filter rows?

Use this pattern: df[df$x > 1, ] subset(df, x > 1)

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