title: R Function to calculate percentage of vector below the mean
body: <p>I have pulled in a csv file from a url and cleaned it up. I am now trying to create a function that takes two inputs, a vector and a number, and tells you the percentage of values in the vector that fall below the number. The vector will be dfStates$jul2011, and the number will be the mean of dfStates$jul2011. Can anyone point me in the right direction to creating this function? </p>
  
  <pre><code>readStates &lt;- read.csv(url("http://www2.census.gov/programs-
  surveys/popest/tables/2010-2011/state/totals/nst-est2011-01.csv"))  #Assign 
  readStates
  
  readStates[6:10] &lt;- list(NULL) #Remove Variables x.4-x.8
  
  readStates &lt;- readStates[-c(1, 2, 3, 4, 5, 6, 7, 8, 60, 61, 62, 63, 64, 65, 
  66, 67),] #Remove Rows
  
  colnames(readStates)[1] &lt;- "stateName"                                                       
  #Fix Column Name  
  colnames(readStates)[2] &lt;- "base2010"                                                        
  #Fix Column Name
  colnames(readStates)[3] &lt;- "base2011"                                                        
  #Fix Column Name
  colnames(readStates)[4] &lt;- "jul2010"                                                         
  #Fix Column Name
  colnames(readStates)[5] &lt;- "jul2011"                                                         
  #Fix Column Name
  
  dfStates &lt;- 
  as.data.frame(sapply(readStates,gsub,pattern="\\.",replacement=""))              
  #Remove Periods
  
  dfStates &lt;- as.data.frame(sapply(dfStates,gsub,pattern=",",replacement=""))                  
  #Remove Commas  
  
  dfStates$base2010 &lt;- as.numeric(as.character(dfStates$base2010))                             
  #Set as Numeric
  dfStates$base2011 &lt;- as.numeric(as.character(dfStates$base2011))                             
  #Set as Numeric
  dfStates$jul2010 &lt;- as.numeric(as.character(dfStates$jul2010))                               
  #Set as Numeric
  dfStates$jul2011 &lt;- as.numeric(as.character(dfStates$jul2011))                               
  #Set as Numeric
  </code></pre>