argument ".f" is missing, with no default

Hi

I'm new to R, so I need to get this process ( below ) to load data and produce to run a proof of concept.
The output should be a listing of the text file contents but re-arranged.

  patient_data <- read_csv("//<server1>/<share1>/User4/Data/input_case.txt")
  patient_data %>%
       # recode lifecycle variable appropriately
       dplyr::mutate(registration_type = forcats::fct_recode("start_time" = "started",
                                                             "end_time" = "completed")) %>%
       convert_timestamps(columns = "time", format = ymd_hms) %>%
       eventlog(case_id = "who",
                activity_id = "what",
                activity_instance_id = "handling") 

      
      Error in `dplyr::mutate()`:
      ! Problem while computing `registration_type = forcats::fct_recode(start_time =
        "started", end_time = "completed")`.
      Caused by error in `check_factor()`:
      ! argument ".f" is missing, with no default
      Run `rlang::last_error()` to see where the error occurred.
      > rlang::last_error()
      <error/dplyr:::mutate_error>
      Error in `dplyr::mutate()`:
      ! Problem while computing `registration_type = forcats::fct_recode(start_time =
        "started", end_time = "completed")`.
      Caused by error in `check_factor()`:
      ! argument ".f" is missing, with no default
      ---
      Backtrace:
        1. ... %>% ...
       11. forcats::fct_recode(start_time = "started", end_time = "completed")
       12. forcats:::check_factor(.f)
      Run `rlang::last_trace()` to see the full context.
      > rland::last_trace()
      Error in loadNamespace(name) : there is no package called ‘rland’
      > rlang::last_trace()
      <error/dplyr:::mutate_error>
      Error in `dplyr::mutate()`:
      ! Problem while computing `registration_type = forcats::fct_recode(start_time =
        "started", end_time = "completed")`.
      Caused by error in `check_factor()`:
      ! argument ".f" is missing, with no default
      ---
      Backtrace:
           x
        1. +-... %>% ...
        2. +-bupaR::eventlog(., case_id = "who", activity_id = "what", activity_instance_id = "handling")
        3. +-bupaR::convert_timestamps(., columns = "time", format = ymd_hms)
        4. | +-base::stopifnot("data.frame" %in% class(x))
        5. | \-"data.frame" %in% class(x)
        6. +-dplyr::mutate(...)
        7. +-dplyr:::mutate.data.frame(...)
        8. | \-dplyr:::mutate_cols(.data, dplyr_quosures(...), caller_env = caller_env())
        9. |   +-base::withCallingHandlers(...)
       10. |   \-mask$eval_all_mutate(quo)
       11. +-forcats::fct_recode(start_time = "started", end_time = "completed")
       12. | \-forcats:::check_factor(.f)
       13. \-base::.handleSimpleError(...)
       14.   \-dplyr h(simpleError(msg, call))
       15.     \-rlang::abort(...)

Thanks for the code.

I am not quite sure what you are doing here I think you may be over-complicating things.
We need some sample data here. It can be mock-up data as long as it matches the data structure of the actual data.

Also

fct_recode("start_time" = "started",   "end_time" = "completed")

will not work . You need a variable in that statement plus the syntax looks incorrect.
See the example on pg 14 of Package ‘forcats.

OOPS, forgot. A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need.

Hi

I think I've worked it out, the line

dplyr::mutate(registration_type = forcats::fct_recode("start_time" = "started",

should be

dplyr::mutate(registration_type = forcats::fct_recode(registration_type, "start_time" = "started",

Then it worked.

Thanks everyone.

Ah, great

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

https://support.rstudio.com/hc/en-us/articles/200534577-Resetting-RStudio-Desktop-s-Statehttps://community.rstudio.com/t/faq-how-do-i-mark-a-solution/5633

Thanks everyone for their help!

This topic was automatically closed 7 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.