[R] Odp: Regression and data types
Petr PIKAL
petr.pikal at precheza.cz
Fri Sep 26 16:29:48 CEST 2008
Hi
r-help-bounces at r-project.org napsal dne 26.09.2008 14:17:59:
> Dear All
> I have three data sets, X1, X2 and Y. X1 is data, X2 and Y were
> generated in (different) R programs. All three vectors have one column
> of 60 data points.
> I am using the code lm(Y~X1)$coef and lm(Y~X2)$coef. The first returns
> two values, an intercept and a slope, but the second returns 60 values.
> I suspect there is something in the "type" of X2 such that it forces the
> regression to do something different, but I can't work this out.
try
str(X2)
it is probably character vector or factor, so you need to transfer it to
numeric.
see ?as.numeric and beware of factor properties (if X2 is factor)
Regards
Petr
> Please help!
> Lewis
>
>
> **********************************************************************
> Hermes Fund Managers Limited
> Registered in England No. 1661776, Lloyds Chambers, 1 Portsoken Street,
London E1 8HZ
>
> *** Please read the Hermes email disclaimer at
http://www.hermes.co.uk/email_terms.htm
> before acting on this email or opening any attachment ***
>
> The contents of this email are confidential. If you have received this
> message in error, please delete it immediately and contact the sender
directly
> or the Hermes IT Helpdesk on +44(0)20 7680 2117. Any reliance on, use,
> disclosure, dissemination, distribution or copying of this email is
> unauthorised and strictly prohibited.
>
> This message has been checked for viruses but the recipient is strongly
> advised to rescan the message before opening any attachments or attached
> executable files. Hermes do not accept any liability for any damage
sustained
> as a result of a virus introduced by this email or any attachment.
>
>
> **********************************************************************
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
>
> ______________________________________________
> 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.
More information about the R-help
mailing list