ts in r 1

ts in r

# Construct monthly time series PR
library(lubridate)
starting_month=month(ymd(monthly_Value$Month[1]))
starting_year=year(ymd(monthly_Value$Month[1]))

library(TTR)
Value.ts <- ts(monthly_Value$Value, start = c(starting_year,starting_month), frequency = 12)
plot(Value.ts)

Here is what the above code is Doing:
1. We are using the lubridate package to extract the month and year from the first date in the dataframe.
2. We are using the TTR package to create a time series object.
3. We are plotting the time series object.

Similar Posts