[R] Plotting a date variable after GAM

Shige Song
Wed, 14 Dec 2011 16:31:04 -0000

Dear Jean,

That is a simple and effective solution. Thank you!

Best,
Shige

On Tue, Dec 13, 2011 at 4:16 PM, Jean V Adams <jvadams at usgs.gov>
wrote:
>
> Shige Song wrote on 12/12/2011 07:49:39 PM:
>
>
>> Dear All,
>>
>> I am fitting a simple GAM model using the "gam" function in
the "mgcv"
>> package. The only independent variable is a continuous variable
>> representing the time of the event (in year and month) coded so that
>> "0" represents January 1960, "1" represents
February 1960, etc. Now
>> when I try to plot the results, my x-axis ranges from "-200"
to "200",
>> what I want is to convert these number into something like
"1950-01"
>> or "Jan. 1950". What is the best way to do this?
>>
>> Many thanks.
>>
>> Best,
>> Shige
>
>
> How about decimal years? ?Would that suffice?
>
> yourdates <- -200:200
> dec.year <- 1960 + yourdates/12
>
> Jean