[R] using factor variable in the "DO" function

Veerappa Chetty chettyvk at gmail.com
Mon Mar 7 19:48:28 CET 2016


Hi,

The following call does not work:

dfhosp=dat.2.wide.sub %>% group_by(HOSP_NRD)%>%
  do(fitHosp=lm(log(y)~ log(x)+I(log(x)^2)+NCHRONIC+AGE+sex ,data=.))

Error in `$<-.data.frame`(`*tmp*`, "sex", value = integer(0)) :
  replacement has 0 rows, data has 25174

When I use "sex" as a binary variable with values "0" and "1", it works.

Is there a way to use factor in this call?
Thanks.

V.K.Chetty

-- 
Professor of Family Medicine
Boston University
Tel: 617-414-6221, Fax:617-414-3345
emails: chettyvk at gmail.com,vchetty at bu.edu

	[[alternative HTML version deleted]]



More information about the R-help mailing list