[R] Multiple left hand side variables in a formula
Frank Harrell
f.harrell at vanderbilt.edu
Sat Mar 2 14:15:24 CET 2013
Hi Gabor,
This is not for a regression function but for a major update I'm working on
for the summary.formula function in the Hmisc package. So I need to handle
several data types in the formula.
Thanks
Frank
Gabor Grothendieck wrote
>> Gabor Grothendieck wrote
>>> On Fri, Mar 1, 2013 at 7:16 PM, Frank Harrell <
>>
>>> f.harrell@
>>
>>> > wrote:
>>>> The lattice package uses special logic to allow for multiple
>>>> left-hand-side
>>>> variables in a formula, e.g. y1 + y2 ~ x. Is there an elegant way to
>>>> do
>>>> this outside of lattice? I'm trying to implement a data summarization
>>>> function that logically takes multiple dependent variables. The usual
>>>> invocation of model.frame( ) causes R to try to do arithmetic addition
>>>> to
>>>> create a single dependent variable.
>>>>
>>>
>>> Try:
>>>
>>> lm( cbind(Sepal.Length, Sepal.Width) ~., iris)
>>>
>
> On Fri, Mar 1, 2013 at 8:02 PM, Frank Harrell <
> f.harrell@
> > wrote:
>> Thanks for your reply Gabor. That doesn't handle a mixture of factor and
>> numeric variables on the left hand side.
>> Frank
>>
>
> It can handle 2 level factors
>
> lm(cbind(Sepal.Length, setosa = Species == "setosa") ~ ., iris)
>
> and more with some manual effort:
>
> lm(cbind(virginica = Species == "virginica", setosa = Species ==
> "setosa") ~ ., iris)
>
> Typically you don't see more than that as a dependent variable. Do
> you actually need more?
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>
> ______________________________________________
> R-help@
> 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.
-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/Multiple-left-hand-side-variables-in-a-formula-tp4660060p4660081.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list