Use as.POSIXct instead of as.POSIXlt if you want to use lm() on the dates.
(The data.frame() function makes this transformation for you, but you
evaded data.frame() by adding the column with $<-(), which does not
do the checks and transformations that data.frame() does.)
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at
r-project.org] On Behalf
> Of Marlin Keith Cox
> Sent: Tuesday, December 17, 2013 12:49 PM
> To: r-help at r-project.org
> Subject: [R] Time series and lm
>
> Hello all, I have a time series defined by
>
> chum$Time1<-as.POSIXlt(chum$Time, format= "%m/%d/%y %H:%M")
>
> and a measured parameter
>
> pa.s
>
> When I create a linear model
>
> with(chum.skin, lm(Time1~pa.s))
>
> I get the following error.
>
> Error in model.frame.default(formula = Time1 ~ pa.s, drop.unused.levels
> TRUE) : invalid type (list) for variable 'Time1'
> I cannot figure it out.
>
> Keith
>
>
>
>
> M. Keith Cox, Ph.D.
> Principal
> MKConsulting
> 17105 Glacier Hwy
> Juneau, AK 99801
> U.S. 907.957.4606
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.