R Markdown

library(lubridate) library(tsibble) library(ggplot2) df <- data.frame( date = c(“2020-01-15”, “2020-02-28”, “2020-03-31”), revenue = c(100, 150, 200) )

Convert to Date format

df\(date <- as.Date(df\)date)

Or, convert from separate year/month/day columns

year <- c(2020, 2020, 2020) month <- c(1, 2, 3) day <- c(15, 28, 31) df$date <- as.Date(paste(year, month, day, sep = “-”))

Create a time series object

ts_data <- ts(data = df$date, start = start_date, end = end_date, frequency = frequency)

Now you can use ‘ts_data’ in your analysis

Create a tsibble object

tsib <- as_tsibble(df, key = NULL) fit <- lm(revenue ~ budget_x + score, data = movies) plot(fit) summary(fit) ggplot(fit, aes(x = .fitted, y = .resid)) + geom_point() + geom_smooth() p <- ggplot(data = movies, aes(x = budget_x))