Re: [R] using string as variable name in model

From: Roni Kobrosly <slyron84_at_gmail.com>
Date: Fri, 04 Jun 2010 11:53:59 -0400

update() works!
Thank you thomas

On Jun 4, 2010, at 11:47 AM, Thomas Lumley wrote:

> 
> 
> I think you're looking for the update() function.
> 
>   -thomas
> 
> On Thu, 3 Jun 2010, Roni Kobrosly wrote:
> 

>> Hi,
>>
>> I made a small table of strings that will serve as variable names for lm models I will run. The table looks like this:
>>
>>> varnames

>> num name
>> 1 1 zCANTAB_log_IED_totaltrials
>> 2 2 zCANTAB_log_IED_preED
>> 3 3 zCANTAB_logPALerrors
>> 4 4 zCANTAB_PALstages
>> 5 5 zCANTAB_logRTI
>> 6 6 zCANTAB_RVP_Totalmisses
>> 7 7 zCANTAB_log_RVP_falsealarm
>> 8 8 zCANTAB_DMS_12000
>> 9 9 zCANTAB_PRM_Percent
>> 10 10 zCANTAB_SRM_Percent
>> 11 11 zCANTAB_sqrt_SWM_within
>> 12 12 zCANTAB_sqrt_SWM_Total
>> 13 13 zSS_WJ_PC
>> 14 14 zSS_WJ_CALC
>> 15 15 zSS_WJ_LW
>> 16 16 zSS_WJ_AP
>> 17 17 zSS_WJ_MF
>>
>>
>> What I'm trying to do is
>>
>>
>> varnames[1,2] -> outcome
>>
>> lm(outcome ~ income + covariate1 + coviarate2, data=my.data) -> model
>>
>> I get the following error message:
>> "Error in model.frame.default(formula = outcome ~ Hollings_Enroll + Child_sex + :
>> variable lengths differ (found for 'Hollings_Enroll')"
>>
>> But when I run the model:
>> lm(zCANTAB_log_IED_totaltrials ~ income + covariate1 + coviarate2, data=my.data) -> model
>>
>> it works fine. Eventually, once I resolve this, I'd like to make a custom R function to automatically generate 17 regression models with these 17 outcome variable strings. Do you have any ideas how to resolve this error?
>>
>> Thanks!
>> -Roni
>>
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> Thomas Lumley			Assoc. Professor, Biostatistics
> tlumley_at_u.washington.edu	University of Washington, Seattle
> 

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 04 Jun 2010 - 19:00:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Jun 2010 - 19:10:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive