From: Rolf Turner <r.turner_at_auckland.ac.nz>

Date: Tue, 04 Mar 2008 12:24:12 +1300

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 Mon 03 Mar 2008 - 23:45:51 GMT

Date: Tue, 04 Mar 2008 12:24:12 +1300

I.e. what is wanted is that if ``condition'' is TRUE then the formula should be

freeny.y ~ freeny.x[,-4] + freeny.x[,4]

There are however different approaches to the problem, ***not*** using NULL.

fff <- if(connie) as.formula(freeny.y ~ freeny.x) else as.formula (freeny.y ~ freeny.x[,-4])

fff <- if(connie) y ~ . else y ~ . - market.potential fit <- lm(fff,data=freeny)

Where ``connie'' is some condition (with value either TRUE or FALSE).

Formulae can also be constructed as text strings (e.g. using
``paste'') and then converted

to actual formulae using as.formula().

**HTH.
**
cheers,

Rolf Turner

On 4/03/2008, at 11:34 AM, <markleeds_at_verizon.net> wrote:

>> From: Matthieu Stigler <stigler3@etu.unige.ch>

*>> Date: 2008/03/03 Mon PM 04:07:09 CST
**>> To: r-help_at_r-project.org
**>> Subject: [R] How to include an externally defined NULL value in lm
**>
**> maybe you should a<-0 unless there's special
**> behavior of NULL that's unknownst to me ?
**>
**>
**>> Hello!
**>>
**>> I would love to be able to include an external variable to a lm
**>> call, I
**>> mean something:
**>>
**>> if(TRUE)
**>> a<-freeny.x[,4]
**>> else
**>> a<-NULL
**>>
**>> lm(freeny.y~freeny.x[,-4] +a)
**>>
**>> but it does not work with a<-NULL, whereas
**>>
**>> lm(freeny.y~freeny.x[,-4] +NULL)
**>>
**>> I don't understand why and did not find an answer in the
**>> manuals... do
**>> you see it? Any idea?
**>>
**>> Thanks!!
**>>
**>> ______________________________________________
**>> 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.
**>
**> ______________________________________________
**> 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.
*

######################################################################Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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 Mon 03 Mar 2008 - 23:45:51 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 Tue 04 Mar 2008 - 01:30:18 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.
*