stevensanderson,
@stevensanderson@mstdn.social avatar

In base R, we can filter rows where a column is between two values using bracket notation or the subset() function along with logical operators like >=, <=, &, and !. The key is creating a logical test that checks if values are within our desired range.

For example, to filter rows where the column "value" is between 5 and 8

df[df$value >= 5 & df$value <= 8,]

Or with subset()

subset(df, value >= 5 & value <= 8)

Post: https://www.spsanderson.com/steveondata/posts/2024-03-01/

#R

image/png

  • All
  • Subscribed
  • Moderated
  • Favorites
  • datascience
  • tester
  • magazineikmin
  • khanakhh
  • InstantRegret
  • thenastyranch
  • Youngstown
  • everett
  • mdbf
  • slotface
  • ngwrru68w68
  • DreamBathrooms
  • kavyap
  • osvaldo12
  • rosin
  • JUstTest
  • Durango
  • tacticalgear
  • modclub
  • cubers
  • GTA5RPClips
  • ethstaker
  • normalnudes
  • cisconetworking
  • Leos
  • megavids
  • provamag3
  • anitta
  • lostlight
  • All magazines