title: Running a linear model in R with spreadsheet data
body: <p>I have a dataset consisting of 106 individuals of two types - a and b with various variables, for example age and gender. I want to run a linear model which predicts whether each individual is of type a or type b based on the co-variates.</p>
  
  <p>I read in the values for age, gender and the type label for each individual using:</p>
  
  <pre><code>`data = read.xlsx("spreadsheet.xlsx",2, as.is = TRUE)`
  age = data$age
  gender = data$gender
  type = data$type
  </code></pre>
  
  <p>where each is of the form:</p>
  
  <pre><code>age = [28, 30, 19, 23 etc]
  gender = [male, male, female, male etc]
  type = [a b b b]
  </code></pre>
  
  <p>Then I try to set up the model using: </p>
  
  <pre><code>model1 = lm(type ~ age + gender)
  </code></pre>
  
  <p>but I get this error message:</p>
  
  <pre><code>Warning messages:
  1: In model.response(mf, "numeric") :
  using type="numeric" with a factor response will be ignored
  2: In Ops.factor(y, z$residuals) : - not meaningful for factors
  </code></pre>
  
  <p>I've tried changing the format of type, age and gender using:</p>
  
  <pre><code>age = as.numeric(as.character(age))
  gender = as.character(gender)
  type = as.character(type)
  </code></pre>
  
  <p>But this doesn't work!  </p>