I\'ve searched on SO trying to find a solution to no avail. So here it is. I have a data frame with many columns, some of which are numerical and should be non-negative. I w
This will give you a vector of your rows that are less than 0:
desired_rows <- sapply(target_columns, function(x) which(df[,x]<0), simplify=TRUE)
desired_rows <- as.vector(unique(unlist(desired_rows)))
Then to get a df of your desired rows:
setdiff(df, df[desired_rows,])
id sth1 tg1_num sth2 tg2_num others
1 1 dave 2 ca 35 new
2 4 leroy 0 az 25 old
3 5 jerry 4 mi 55 old