-1

In a dataframe for example

mtcars
               mpg cyl disp  hp drat   wt ... 
Mazda RX4     21.0   6  160 110 3.90 2.62 ... 
Mazda RX4 Wag 21.0   6  160  98 3.90 2.88 ... 
Datsun 710    22.8   4  108  93 3.85 2.32 ...

I want to show the rows where column 2 (cyl) is greater than 5 AND column 4 (hp) is greater than 100

therefore resulting in Mazda RX4

I know how to do it with 1 column

df[(df[,2]>5),]

but i don't know how to chain the two together

Maurice
  • 53
  • 3
  • 9

1 Answers1

0

dfSub = subset(df, cyl > 5 & hp > 100)

spazznolo
  • 747
  • 3
  • 9