Error in mutate_impl(.data, dots) : Evaluation error: 'from' must be a finite number
I have a large dataset (19945862 obs. of 3 variables) and I am building a time series model for around 50,000 members. Below is the script I am using.
memeberid date amount
165595 17471 2
165596 17471 1.99
165596 17471 1.29
165597 17471 0.88
...... 19945858 obs
library(sweep)
library(tidyquant)
library(forecast)
library(timetk)
yearweek <- function(x) structure(floor(52*x + .00001)/52, class = "yearweek")
reaaranging the data by week
ts$date <- as.numeric(ts$date)
weekly_amt_by_member <- ts %>%
mutate(order.week = as_date(yearweek(date))) %>%
group_by(memberid, order.week) %>%
summarise(total.amt = sum(amount))
bundleing the data on memeberid using nest()
weekly_amt_by_member_nest <- weekly_amt_by_member %>%
group_by(memberid) %>%
nest(.key = "data.tbl")
mutate and map memberid bundles and function to ts class object
weekly_amt_by_member_ts <- weekly_amt_by_member_nest %>%
mutate(data.ts = map(.x = data.tbl ,
.f = tk_ts ,
select = -order.week ,
start = 2017 ,
freq = 52))
modelling ets model
weekly_amt_by_member_fit <- weekly_amt_by_member_ts %>%
mutate(fit.ets = map(data.ts , ets))
forecasting the model
weekly_amt_by_member_fcast <- weekly_amt_by_member_fit %>%
mutate(fcast.ets = map(fit.ets , forecast , h = 52))
All the above parts are running without error except the last part (forecasting the model) which is giving me the following error:
Error in mutate_impl(.data, dots) :
Evaluation error: 'from' must be a finite number.
r time-series mutate unnest
add a comment |
I have a large dataset (19945862 obs. of 3 variables) and I am building a time series model for around 50,000 members. Below is the script I am using.
memeberid date amount
165595 17471 2
165596 17471 1.99
165596 17471 1.29
165597 17471 0.88
...... 19945858 obs
library(sweep)
library(tidyquant)
library(forecast)
library(timetk)
yearweek <- function(x) structure(floor(52*x + .00001)/52, class = "yearweek")
reaaranging the data by week
ts$date <- as.numeric(ts$date)
weekly_amt_by_member <- ts %>%
mutate(order.week = as_date(yearweek(date))) %>%
group_by(memberid, order.week) %>%
summarise(total.amt = sum(amount))
bundleing the data on memeberid using nest()
weekly_amt_by_member_nest <- weekly_amt_by_member %>%
group_by(memberid) %>%
nest(.key = "data.tbl")
mutate and map memberid bundles and function to ts class object
weekly_amt_by_member_ts <- weekly_amt_by_member_nest %>%
mutate(data.ts = map(.x = data.tbl ,
.f = tk_ts ,
select = -order.week ,
start = 2017 ,
freq = 52))
modelling ets model
weekly_amt_by_member_fit <- weekly_amt_by_member_ts %>%
mutate(fit.ets = map(data.ts , ets))
forecasting the model
weekly_amt_by_member_fcast <- weekly_amt_by_member_fit %>%
mutate(fcast.ets = map(fit.ets , forecast , h = 52))
All the above parts are running without error except the last part (forecasting the model) which is giving me the following error:
Error in mutate_impl(.data, dots) :
Evaluation error: 'from' must be a finite number.
r time-series mutate unnest
add a comment |
I have a large dataset (19945862 obs. of 3 variables) and I am building a time series model for around 50,000 members. Below is the script I am using.
memeberid date amount
165595 17471 2
165596 17471 1.99
165596 17471 1.29
165597 17471 0.88
...... 19945858 obs
library(sweep)
library(tidyquant)
library(forecast)
library(timetk)
yearweek <- function(x) structure(floor(52*x + .00001)/52, class = "yearweek")
reaaranging the data by week
ts$date <- as.numeric(ts$date)
weekly_amt_by_member <- ts %>%
mutate(order.week = as_date(yearweek(date))) %>%
group_by(memberid, order.week) %>%
summarise(total.amt = sum(amount))
bundleing the data on memeberid using nest()
weekly_amt_by_member_nest <- weekly_amt_by_member %>%
group_by(memberid) %>%
nest(.key = "data.tbl")
mutate and map memberid bundles and function to ts class object
weekly_amt_by_member_ts <- weekly_amt_by_member_nest %>%
mutate(data.ts = map(.x = data.tbl ,
.f = tk_ts ,
select = -order.week ,
start = 2017 ,
freq = 52))
modelling ets model
weekly_amt_by_member_fit <- weekly_amt_by_member_ts %>%
mutate(fit.ets = map(data.ts , ets))
forecasting the model
weekly_amt_by_member_fcast <- weekly_amt_by_member_fit %>%
mutate(fcast.ets = map(fit.ets , forecast , h = 52))
All the above parts are running without error except the last part (forecasting the model) which is giving me the following error:
Error in mutate_impl(.data, dots) :
Evaluation error: 'from' must be a finite number.
r time-series mutate unnest
I have a large dataset (19945862 obs. of 3 variables) and I am building a time series model for around 50,000 members. Below is the script I am using.
memeberid date amount
165595 17471 2
165596 17471 1.99
165596 17471 1.29
165597 17471 0.88
...... 19945858 obs
library(sweep)
library(tidyquant)
library(forecast)
library(timetk)
yearweek <- function(x) structure(floor(52*x + .00001)/52, class = "yearweek")
reaaranging the data by week
ts$date <- as.numeric(ts$date)
weekly_amt_by_member <- ts %>%
mutate(order.week = as_date(yearweek(date))) %>%
group_by(memberid, order.week) %>%
summarise(total.amt = sum(amount))
bundleing the data on memeberid using nest()
weekly_amt_by_member_nest <- weekly_amt_by_member %>%
group_by(memberid) %>%
nest(.key = "data.tbl")
mutate and map memberid bundles and function to ts class object
weekly_amt_by_member_ts <- weekly_amt_by_member_nest %>%
mutate(data.ts = map(.x = data.tbl ,
.f = tk_ts ,
select = -order.week ,
start = 2017 ,
freq = 52))
modelling ets model
weekly_amt_by_member_fit <- weekly_amt_by_member_ts %>%
mutate(fit.ets = map(data.ts , ets))
forecasting the model
weekly_amt_by_member_fcast <- weekly_amt_by_member_fit %>%
mutate(fcast.ets = map(fit.ets , forecast , h = 52))
All the above parts are running without error except the last part (forecasting the model) which is giving me the following error:
Error in mutate_impl(.data, dots) :
Evaluation error: 'from' must be a finite number.
r time-series mutate unnest
r time-series mutate unnest
edited Nov 29 '18 at 18:39
ABHIK ARORA
asked Nov 20 '18 at 22:55
ABHIK ARORAABHIK ARORA
63
63
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402820%2ferror-in-mutate-impl-data-dots-evaluation-error-from-must-be-a-finite-nu%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402820%2ferror-in-mutate-impl-data-dots-evaluation-error-from-must-be-a-finite-nu%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown