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) )
df\(date <- as.Date(df\)date)
year <- c(2020, 2020, 2020) month <- c(1, 2, 3) day <- c(15, 28, 31) df$date <- as.Date(paste(year, month, day, sep = “-”))
head(df) library(ggplot2) df\(date <- as.Date(df\)date) library(ggplot2) df\(date <- as.Date(df\)date) library(ggplot2) library(lubridate) df\(date <- as.Date(df\)date ) library(ggplot2) library(lubridate) df\(date <- as.Date(df\)date) df\(date <- as.Date(df\)date) # Create a time series data frame class(frequency) frequency <- 12 # Replace 12 with your actual frequency value frequency <- as.numeric(frequency) frequency <- function(x) { … } # Assuming df$date is a vector of date values start_date <- as.Date(“2023-01-01”) end_date <- as.Date(“2023-12-31”) frequency <- 12
ts_data <- ts(data = df$date, start = start_date, end = end_date, frequency = frequency)
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))