problems with select()

640 views
Skip to first unread message

Stefanka Chukova

unread,
May 22, 2017, 12:27:09 AM5/22/17
to simmer-devel
I was going over http://r-simmer.org/articles/C-trajectories.html  Advanced Trajectory Usage
and the code below, which is from section select()

==================================================================
library(simmer)
patient_traj <- trajectory(name = "patient_trajectory") %>%
  set_attribute("resource", function() sample(1:3, 1)) %>%
  select(resources = function(attrs) paste0("doctor", attrs["resource"])) %>%
  seize_selected(amount = 1) %>%
  timeout(5) %>%
  release_selected(amount = 1)

env <- simmer() %>%
  add_resource("doctor1", capacity = 1) %>%
  add_resource("doctor2", capacity = 1) %>%
  add_resource("doctor3", capacity = 1) %>%
  add_generator("patient", patient_traj, at(0, 1, 2), mon = 2) %>%
  run()

get_mon_attributes(env)
============================================================
produces the following error:
Error in UseMethod("select_") : 
  no applicable method for 'select_' applied to an object of class "c('trajectory', 'R6')"
Why is that? How does simmer know that this is not select() from package dplyr?

Iñaki Úcar

unread,
May 22, 2017, 4:44:25 AM5/22/17
to simmer-devel
Hi Stefanka,

There is a namespace collision between simmer's select() and dplyr's when both packages are loaded. If you are using both of them, I recommend using simmer::select() and dplyr::select() instead of just select() to avoid this problem.

Regards,
Iñaki

Why it that? How does simmer know that this is not select() from package dplyr?

--
You received this message because you are subscribed to the Google Groups "simmer-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simmer-devel+unsubscribe@googlegroups.com.
To post to this group, send email to simmer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/simmer-devel/7dd69791-1bc1-4972-b724-072433f63ca3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages