Gracefully removing observations with outliers in N fields
This will achieve what you want. You can remove outliers from any column you wish, just pass that column number as an argument in the function.  

id &lt;- c(12,23,34,45,56,67)
num &lt;- c(5,9,2,99,3,4)
prac &lt;- data.frame(id, num)


remove_outliers &lt;- function(x, col) {

  #find position of 1st and 3rd quantile not including NA's
  qnt &lt;- quantile(x[ ,col], probs=c(.25, .75), na.rm = TRUE)

  H &lt;- 1.5 * IQR(x[ ,col])

  x[ ,col] &lt;- ifelse(x[ ,col] &lt; (qnt[1] - H) | x[ ,col] &gt; (qnt[2] + H), NA, x[ ,col])


  #get rid of any NA's
  x &lt;- x[!is.na(x[ ,col]), ]
  x &lt;- assign("dataset", x, envir = .GlobalEnv)
  return(x)
}

remove_outliers(prac, 2)