[R] LM() and time in R

Jim Lemon drjimlemon at gmail.com
Thu Apr 30 00:59:32 CEST 2015


Hi Livia,
>From your description, it sounds like the "time" variable is actually
a vector of date strings like "30/04/2015". These will usually be
input as "factors" in R, meaning that you probably had a very large
number of categorical values instead of numeric. To find out, do this:

is.factor(time_variable)

where "time_variable" is something like mydata$Time. If the answer is
TRUE, convert that variable to a vector of dates with as.Date and try
your analysis again.

Jim


On Thu, Apr 30, 2015 at 4:25 AM, Boris Steipe <boris.steipe at utoronto.ca> wrote:
> Have a look at the help page for the function ts()
> (type ?ts  at the R prompt).  Other than that, you haven't provided nearly enough information for us to diagnose your issue.
>
> Please see here for some hints on how to ask questions productively:
> http://adv-r.had.co.nz/Reproducibility.html
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> Cheers
>
> B.
>
> On Apr 29, 2015, at 6:26 AM, Livia Maria Vestergaard <lvest09 at student.sdu.dk> wrote:
>
>>
>> Hello,
>>
>> I need some help with a project that I’m working one.
>>
>> Im trying to make a l regression model (lm) in r with time as independant variable and gas prices as the depended.
>> But It seems like everything im trying to run it, R freeze, I think that I need to tell R somehow that my time is time but how ?
>>
>>
>>
>> Hope that you can help me :)
>> Livia
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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 -- To UNSUBSCRIBE and more, see
> 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