Select rows, columns, and cells three different ways
data: palmerpenguins::penguinsn = 15 rows shown
Indexing Method
Which column?
The $ operator always returns all rows as a vector.
Row index (left of comma)
Column index (right of comma)
Subsetting rows (base R filter)
Equivalent to dplyr's filter(); it keeps rows where a condition is TRUE
Column:
Operator:
Value:
Add a second condition using:
Condition 2:
Column:
Operator:
Value:
Data Table
#
species
island
bill_length_mm
flipper_length_mm
body_mass_g
sex
R Code
$ operator
[ , ] brackets
Boolean filter
Here's how this works.
The code panel above shows real R code you can paste into R. The colored stripe on the left of each line marks which indexing concept it belongs to: blue for $, green for [ , ], amber for Boolean subsetting.
The data table in the middle highlights exactly what gets selected: which rows, which columns, or which cells. Use the controls on the left to change the method and options. The code, the table, and this explanation all update instantly each time you click something.