Time series with daily Frequency

Hey, I have this data but, I couldn't be able to fit the Ts on the data perfectly that will plot the correct time plot for the data.

Here is my data:

s <- read.csv(url('https://ondemand.websol.barchart.com/getHistory.csv?apikey=c3122f072488a29c5279680b9a2cf88e&symbol=zs*1&type=dailyNearest&backAdjust=false&startDate=20100201'))

Here is my code:

data <- s[c(3, 7)]
summary(data)
ts_soy <- ts(data[,2], start = c(2010-02-01), frequency = 365.25)
autoplot(ts_soy)

When I loaded the data "tradingDay" had a character class, so R was treating it like text, not a date.

I think that may have been your issue.

I'm not sure what you're going for in the end, but maybe something like this?

library(tidyverse)
library(lubridate)

# Coerce tradingDay to date format (and make data a tibble, unnecessary, but nice)
data <- as_tibble(data) %>% 
  mutate(tradingDay = as_date(tradingDay))

# Simple plot of time series
ggplot(data, aes(x = tradingDay, y = close)) + geom_line()

I hope that helps,

Luke

1 Like

hey, thanks for reaching out, I want to run arima forecasting on it. But my frequency is off.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.