Thank you Roy, great suggestion, reviewing the link and trying steps now. WHP
From: Roy Mendelssohn - NOAA Federal <[email protected]> Sent: Saturday, June 15, 2019 3:49 PM To: Bill Poling <[email protected]> Cc: Richard M. Heiberger <[email protected]>; r-help ([email protected]) <[email protected]> Subject: Re: [R] Help with a third ggplot error If I were a betting man I would bet that one of the things in your "pipeline" isn't returning what you think it is. You can either break it out step by step to check or this page lists a variety of resources to debug pipes: https://www.rostrum.blog/2019/04/07/fix-leaky-pipes/ HTH, -Roy > On Jun 15, 2019, at 12:29 PM, Bill Poling <mailto:[email protected]> > wrote: > > Hello Richard, thank you for your response. > > Here is what I get with your suggestion, however, I am unsure of what I am > looking at, perhaps you can interpret. > > I sure appreciate your help Sir! > > g4 <- fcast_arima_tbl1 %>% > ggplot(aes(date, NetEditRev, color = key)) + #Now date due to sweep > geom_point(data = test_tbl %>% mutate(key = "actual")) + > geom_point(alpha = 0.5) + > theme_tq() + > scale_color_tq() + > labs(title = "ARIMA(1,0,2)(0,1,0 with Drift For Net Edit Revenue") > > g4 > > #Don't know how to automatically pick scale for object of type function. > Defaulting to continuous. > #Error: All columns in a tibble must be 1d or 2d objects: > #* Column `x` is function > > ggplotly(g4) %>% > layout(xaxis = list(rangeslider = list(type = "date"))) > > #Don't know how to automatically pick scale for object of type function. > Defaulting to continuous. > #Error: All columns in a tibble must be 1d or 2d objects: > #* Column `x` is function > > #Call > rlang::last_error() > #to see a backtrace you will have to figure out which of your variables is > not properly specified. > > 1. (function (x, ...) ... > 2. ggplot2:::print.ggplot(x) > 4. ggplot2:::ggplot_build.ggplot(x) > 5. ggplot2:::by_layer(function(l, d) l$compute_aesthetics(d, plot)) > 6. ggplot2:::f(l = layers[[i]], d = data[[i]]) > 7. l$compute_aesthetics(d, plot) > 8. ggplot2:::f(..., self = self) > 9. ggplot2:::as_gg_data_frame(evaled) > 12. tibble:::as_tibble.list(x) > 13. tibble:::lst_to_tibble(x, .rows, .name_repair, col_lengths(x)) > 14. tibble:::check_valid_cols(x) > > From: Richard M. Heiberger <mailto:[email protected]> > Sent: Saturday, June 15, 2019 3:17 PM > To: Bill Poling <mailto:[email protected]> > Cc: r-help (mailto:[email protected]) <mailto:[email protected]> > Subject: Re: [R] Help with a third ggplot error > > you did something like this: > >> mydf <- data.frame(y=1:16, > + AA=rep(factor(letters[1:8]), 2), > + BB=rep(factor(LETTERS[12:13]), each=8), > + CC=rep(factor(rep(LETTERS[9:11], times=c(3,1,4))), 2)) >> ggplot(mydf, aes(ls, y)) > Don't know how to automatically pick scale for object of type > function. Defaulting to continuous. > Error: All columns in a tibble must be 1d or 2d objects: > * Column `x` is function > Call `rlang::last_error()` to see a backtrace >> > > you will have to figure out which of your variables is not properly specified. > > Rich > > On Fri, Jun 14, 2019 at 3:30 PM Bill Poling <mailto:[email protected]> > wrote: >> >> #RStudio Version 1.2.1335 >> sessionInfo() >> #R version 3.5.3 (2019-03-11) >> #Platform: x86_64-w64-mingw32/x64 (64-bit) >> #Running under: Windows >= 8 x64 (build 9200) >> >> Hello I am fitting an Arima model and all appears to go well until I get to >> the ggplot, (again, lots of laughs). >> Deja Vu all over again! (God I hope it's not a typo!) >> >> The error at the point of the plot is: >> # Don't know how to automatically pick scale for object of type function. >> Defaulting to continuous. >> # Error: All columns in a tibble must be 1d or 2d objects: >> # * Column `x` is function >> >> I hope someone recognizes my problem. >> >> Thank you for any assistance. >> >> #Here is the code and particulars of the data being plotted >> >> #Fit the arima model >> >> fit_arima2 <- train_tbl %>% >> tk_ts(select = NetEditRev, frequency = 364) %>% >> Arima(order = c(1,0,2), >> seasonal=c(0,1,0), >> include.drift = TRUE) >> >> #Forecast with Sweep Functions---- >> >> fcast_arima_tbl <- forecast(fit_arima2, h = nrow(test_tbl)) %>% >> sw_sweep(timetk_idx = TRUE, rename_index = "date") >> >> #Save the DF >> >> fs::dir_create("00_model") >> >> fcast_arima_tbl %>% write_rds("00_model/fcast_arima_tbl.rds") >> >> fcast_arima_tbl1 <- read_rds("00_model/fcast_arima_tbl.rds") >> >> head(fcast_arima_tbl1) >> >> # A tibble: 6 x 7 >> date key NetEditRev lo.80 lo.95 hi.80 hi.95 >> <date> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> >> 1 2017-01-01 actual -923. NA NA NA NA >> 2 2017-01-02 actual 19222. NA NA NA NA >> 3 2017-01-03 actual -8397. NA NA NA NA >> 4 2017-01-04 actual 37697. NA NA NA NA >> 5 2017-01-05 actual 46075. NA NA NA NA >> 6 2017-01-06 actual 38329. NA NA NA NA >> >> str(fcast_arima_tbl1) >> Classes 'tbl_df', 'tbl' and 'data.frame':892 obs. of 7 variables: >> $ date : Date, format: "2017-01-01" "2017-01-02" "2017-01-03" "2017-01-04" >> ... >> $ key : chr "actual" "actual" "actual" "actual" ... >> $ NetEditRev: num -923 19222 -8397 37697 46075 ... >> $ lo.80 : num NA NA NA NA NA NA NA NA NA NA ... >> $ lo.95 : num NA NA NA NA NA NA NA NA NA NA ... >> $ hi.80 : num NA NA NA NA NA NA NA NA NA NA ... >> $ hi.95 : num NA NA NA NA NA NA NA NA NA NA ... >> >> #Plot the model >> >> g4 <- fcast_arima_tbl1 %>% >> ggplot(aes(date, NetEditRev, color = key)) + >> geom_point(data = test_tbl %>% mutate(key = "actual")) + >> geom_point(alpha = 0.5) + >> theme_tq() + >> scale_color_tq() + >> labs(title = "ARIMA(1,0,2)(0,1,0 with Drift For Net Edit Revenue") >> >> g4 >> # Don't know how to automatically pick scale for object of type function. >> Defaulting to continuous. >> # Error: All columns in a tibble must be 1d or 2d objects: >> # * Column `x` is function >> >> ggplotly(g4) %>% >> layout(xaxis = list(rangeslider = list(type = "date"))) >> # Don't know how to automatically pick scale for object of type function. >> Defaulting to continuous. >> # Error: All columns in a tibble must be 1d or 2d objects: >> # * Column `x` is function >> >> >> #Alternative changes that I have tried based on google searches, but have >> their own errors. >> >> # g4 <- fcast_arima_tbl1 %>% >> # ggplot(aes(date, NetEditRev, color = key)) + >> # geom_point(data = test_tbl %>% filter(key = "actual")) + #Try using filter >> # geom_point(alpha = 0.5) + >> # theme_tq() + >> # scale_color_tq() + >> # labs(title = "ARIMA(1,0,2)(0,1,0 with Drift For Net Edit Revenue") >> # #Error: `key` (`key = "actual"`) must not be named, do you need `==`? >> # >> # g4 <- fcast_arima_tbl1 %>% >> # ggplot(aes(date, NetEditRev, color = key)) + >> # geom_point(data = test_tbl %>% filter(key == "actual")) + #Try using >> filter with == >> # geom_point(alpha = 0.5) + >> # theme_tq() + >> # scale_color_tq() + >> # labs(title = "ARIMA(1,0,2)(0,1,0 with Drift For Net Edit Revenue") >> # #Error: object 'key' not found >> # >> # g4 <- fcast_arima_tbl1 %>% >> # ggplot(aes(date, NetEditRev, color = key)) + >> # geom_point(data = test_tbl) + >> # filter(fcast_arima_tbl1$key = "actual") + #Try filter with >> fcast_arima_tbl1$key and repositioned with + >> # geom_point(alpha = 0.5) + >> # theme_tq() + >> # scale_color_tq() + >> # labs(title = "ARIMA(1,0,2)(0,1,0 with Drift For Net Edit Revenue") >> # #Error: Cannot add ggproto objects together. Did you forget to add this >> object to a ggplot object? >> >> Confidentiality Notice This message is sent from Zelis. ...{{dropped:13}} ______________________________________________ [email protected] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

