From the below data frame, I want to apply the subset function():
df<-data.frame(
id=c(1:5),
ax1=c(5,3,7,-1,9),
bx1=c(0,1,-1,0,3),
cx1=c(2,1,5,-1,5),
dx1=c(3,7,2,1,8))
The data set has a variable x1 that is estimated at different time points, denoted by ax1, bx1, cx1, and dx1. I am trying to subset these data by eliminating the rows with -1 on any column like on ax1, bx1, cx1, and dx1. I would like to know if there is a way to automate filtering (or filter function) to perform this task.