title: column index and column name based on a specific value
body: <p>I want to identify column names and index based upon a specific value. Here is my sample dataframe -</p>
  
  <pre><code>set.seed(1)
  age_range = sample(c("ar2-15", "ar16-29", "ar30-44"), 200, replace = TRUE)
  gender = sample(c("M", "F",-999), 200, replace = TRUE)
  region = sample(c("A", "B", "C"), 200, replace = TRUE)
  physi = sample(c("Poor", "Average", "Good"), 200, replace = TRUE)
  height = sample(c(4,5,6,-999), 200, replace = TRUE)
  height2 = sample(c(40,0), 200, replace = TRUE)
  weight2 = sample(c(20,0,-999), 200, replace = TRUE)
  
  survey = data.frame(age_range, gender, region,physi,height,height2,weight2)
  head(survey)
  </code></pre>
  
  <p>How can I find the column names and indices in survey df where -999 exists? I tried using some combination of apply and which, but it did not work. Obviously I am doing something wrong. </p>
  
  <p>EDIT:</p>
  
  <pre><code>&gt; apply(survey,2,function(x) match(-999,x))
  age_range    gender    region     physi    height   height2   weight2 
         NA        10        NA        NA         1        NA         2 
  </code></pre>
  
  <p>This only gives me all column names and shows NA for the ones that don't have -999. Any pointers are highly appreciated. Thanks!
  Jennifer</p>