Error in is.data.frame(.l) : object 'group' not found

530 views Asked by At

Not sure if you all will be able to help me without reproducible example data, but I have a problem with running the code below. I am attempting to use the multidplyr package, but it doesn't seem to find my columns. I am running the code below:

cl <- detectCores()
cl

models_prep <-
  bookings_prep %>%
  inner_join(pipeline_prep_, by = c("booking_type", "group")) %>%
  crossing(biz_day) %>%
  left_join(closed_pipeline, by = c("booking_type", "group")) %>%
  select(-opportunity_forecast_category)

group1 <- rep(1:cl, length.out = nrow(models_prep))
models_prep1 <- bind_cols(tibble(group1), models_prep)


cluster <- new_cluster(cl)

cluster %>%
  cluster_library("tidyr") 

cluster %>%
  cluster_library("purrr") 

cluster %>%
  cluster_library("plyr") 

cluster %>%
  cluster_library("dplyr") 

cluster_copy(cluster, "rmf")
cluster_copy(cluster, "fc_xreg")


#cluster_assign(cluster, "rmf")
#cluster_copy(cluster,c("rmf","fc_xreg"))

by_group <- models_prep %>%
  group_by(group) %>%
  partition(cluster) 

by_group1 <- models_prep1 %>%
  group_by(group1) %>%
  partition(cluster) 

models <-  by_group %>%
  mutate(
    xreg_arima = pmap(list(data = pipeline, h = 1,name = group, bookings = bookings, type = booking_type,
                           biz_day = biz_day, no_bookings = no_bookings,
                           sparse_pipeline = sparse_pipeline,
                           closed_forecast_cat = pipeline_amount, FUN = "fc_xreg"), rmf))

Everything runs up to models <- correctly, but it fails there saying it cannot find the object group. Here is what the by_group data frame looks like.

enter image description here

1

There are 1 answers

2
Davide Lorino On

Sometimes arguments just need to be quoted, particularly in dplyr-ish situations.

models <-  by_group %>%
  mutate(
    xreg_arima = pmap(list(data = pipeline, h = 1,name = "group", bookings = "bookings", type = "booking_type",
                           biz_day = "biz_day", no_bookings = "no_bookings",
                           sparse_pipeline = "sparse_pipeline",
                           closed_forecast_cat = "pipeline_amount", FUN = "fc_xreg"), rmf))