jak123
January 18, 2022, 9:13pm
1
Hi R Com
have the following code:
library(tidymodels)
library(modeltime)
library(tidyverse)
library(timetk)
Collect data
data <- walmart_sales_weekly %>%
select(id, Date, Weekly_Sales) %>%
set_names(c("ID", "date", "value"))
data
sample <- data %>%
mutate(item_id = ID) %>%
filter(as.numeric(item_id) %in% 1:3)
unique(sample$item_id)
i want a sample of 3 item_id with the " filter(as.numeric(item_id %in% 1:3 ) " but when i run unique(sample$item_id) I get only 2 unique values?
thank
Might be because:
unique(data$ID)
# [1] 1_1 1_3 1_8 1_13 1_38 1_93 1_95
Regards,
Grzegorz
jak123
January 19, 2022, 8:09am
3
Because what? not sure i follow
Also i cannot find the functions:
split_nested_timeseries
extend_timeseries
nest:timeseires
have installed modeltime
library(modeltime)
jak123
January 19, 2022, 8:11am
4
the split_nested_timeseries function is showed here:
jak123
January 19, 2022, 8:17am
5
library(tidyverse)
library(timetk)
library(modeltime)
nested_data_tbl <- walmart_sales_weekly %>%
select(id, Date, Weekly_Sales) %>%
set_names(c("id", "date", "value")) %>%
Step 1: Extends the time series by id
extend_timeseries(
.id_var = id,
.date_var = date,
.length_future = 52
) %>%
Step 2: Nests the time series into .actual_data and .future_data
nest_timeseries(
.id_var = id,
.length_future = 52
) %>%
Step 3: Adds a column .splits that contains training/testing indicies
split_nested_timeseries(
.length_test = 52
)
nested_data_tbl
Helpers: Getting the Train/Test Sets
extract_nested_train_split(nested_data_tbl, .row_id = 1)
Error in split_nested_timeseries(., .length_test = 52) :
could not find function "split_nested_timeseries"
Because in the original data set there is no other values than: 1_1, 1_3 , 1_8, 1_13, 1_38, 1_93, 1_95.
Let's assume, you want to remove "1_" and the remaining chars are: 1, 3, 8, etc.
If you are searching for values between 1:3, there is no much, just 1 and 3.
Hope it helps,
Grzegorz
jak123
January 19, 2022, 12:27pm
7
jak123:
split_nested_timeseries(
ahh so if i rename the id column to 1,2,3,4,5,6,7,8,9,10 it works? or what is the solution to this?
Thanks!
system
Closed
February 9, 2022, 12:28pm
8
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.