title: R: variable lengths differ (found for"..") in glm function
body: <pre><code> multiH&lt;- glm(H ~sex+ region+ age+ incm+ edu+ occp + marri_1 + BD1_11+ BS3_1 +HE_BMI ,family=binomial(), na.action="na.exclude",data=hn1)
  # sex with 1,2/ region for 1~10/ age for 30~99/ incm for 1~4/ occp for 1~3/ marri_1 for 1,2/  BD1_11 for 1,2/ BS3_1  for 1,2/ HE_BMI for 0~99 
  </code></pre>
  
  <p>There is no NAs in my data.</p>
  
  <p>Also did use the factor code for some variables.</p>
  
  <p>I do not know the way to solve this error problem.</p>
  
  <p>Which is</p>
  
  <pre><code>#variable lengths differ for "...."
  </code></pre>
  
  <p>Maybe the data frame should be the same, but is not..?</p>
  
  <p>Any help would be appreciated :) </p>
  
  <pre><code>Error in model.frame.default(formula = H ~ sex + region + age + incm +  : 
    variable lengths differ (found for 'sex')
  
  &gt; str(hn1)
  'data.frame':   27887 obs. of  1 variable:
   $ sex.age.incm.edu.occp.marri_1.BD1_11.BS3_1.H.Var: Factor w/ 19847 levels     "1,0,0,0,0,0,0,0,0,0",..: 5222 13979 585 10962 13430 2938 12857 6137 15667 66 ...
  </code></pre>
  
  <p>This is the error sign I get...</p>
  
  <pre><code> &gt;hn1&lt;-read.csv("C:\\Users\\hayon14\\Desktop\\HN.csv", header=T, dec=".",sep="\t"
  &gt; H&lt;-factor(hn1$H)
  &gt; region&lt;-factor(hn1$region)
  &gt; sex&lt;-factor(hn1$sex)
  &gt; age&lt;-factor(hn1$age)
  &gt; incm&lt;-factor(hn1$incm)
  &gt; edu&lt;-factor(hn1$edu)
  &gt; occp&lt;-factor(hn1$occp)
  &gt; marri_1&lt;-factor(hn1$marri_1)
  &gt; BD1_11&lt;-factor(hn1$BD1_11)
  &gt; BS3_1&lt;-factor(hn1$BS3_1)
  &gt; HE_BMI&lt;-factor(hn1$HE_BMI)
  &gt; multiH&lt;- glm(H ~sex+ region+ age+ incm+ edu+ occp + marri_1 + BD1_11+     BS3_1 +HE_BMI ,family=binomial(), na.action="na.exclude",data=hn1)
  </code></pre>
  
  <p>This is my full code.</p>