title: How to specify the Ordering of categorical variables in read.csv in R
body: <p>I am using the <code>read.csv</code> function along with the <code>colClasses</code> parameter for reading my csv file. What i want to achieve is that for all the <code>colClasses</code> that are "factors" , I want to specify the order of the factors .i.e.</p>
  
  <p>If the column "Liquid-type" has the following factors :- "Water' , "Juice" , "Soda" , "Alcohol" , i want to control the ordering of factors .lets say </p>
  
  <pre><code>Water = 3
  Juice=1
  Soda=2
  Alcohol =0 
  </code></pre>
  
  <p>So how can i control the order of factors in <code>read.csv</code>?</p>
  
  <p>Edit: Your comment below, formatted:</p>
  
  <pre><code>setClass("customFactor") 
  setAs("character", "customFactor", function(from) {SpecifyOrders(from)}) 
  SpecifyOrders &lt;- function(from) { 
         from&lt;- factor(from, levels=c(new_order)) }  
  </code></pre>