title: how do I remove question mark(?) from a data set in R
body: <p>Hello everyone I am analysing UCI adult <code>census</code> data. The data has question marks (<code>?</code>) for every missing value.</p>
  
  <p>I want to replace all the question marks with <code>NA</code>.</p>
  
  <p>i tried:</p>
  
  <pre><code>library(XML)
  census&lt;-read.csv("https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data",header=F,na.strings="?")
  names(census)&lt;-c("Age","Workclass","Fnlwght","Education","EducationNum","MaritalStatus","Occupation"   
    ,"Relationship" , "Race","Gender","CapitalGain","CapitalLoss","HoursPerWeek","NativeCountry","Salary"  )
  
  table(census$Workclass)
  
                  ?       Federal-gov         Local-gov      Never-worked           Private      Self-emp-inc 
               1836               960              2093                 7             22696              1116 
   Self-emp-not-inc         State-gov       Without-pay 
               2541              1298                14 
  
  x
  
  &lt;-ifelse(census$Workclass=="?",NA,census$Workclass)
   table(x)
  x
      1     2     3     4     5     6     7     8     9 
   1836   960  2093     7 22696  1116  2541  1298    14
  </code></pre>
  
  <p>but it did not work.</p>
  
  <p>Please help.</p>