I have a dataframe and I want to filter it:
employee <- c('John Doe','Peter Gynn','Jolie Hope', 'Michael')
salary <- c(21000, 23400, 26800, 25000)
number <- c(1,2,3,5)
df <- data.frame(employee,salary,number)
> df
employee salary number
1 John Doe 21000 1
2 Peter Gynn 23400 2
3 Jolie Hope 26800 3
4 Michael 25000 5
I also have these vectors:
vectorMin <- c(22000,1.5)
vectorMax <- c(26000,4.5)
I want to filter the dataframe with the rows which salary between 22000 and 26000 and the number between 1.5 and 4.5. In this case I want the dataframe with only Peter Gynn. I have tried:
(df >= vectorMin) & (df <= vectorMax)
But this doesn´t work. How can I do it?