Running examples in 'confoundr-Ex.R' failed
The error most likely occurred in:

> ### Name: makehistory.one
> ### Title: Function to create exposure history for a single time varying
> ###   exposure.
> ### Aliases: makehistory.one
> 
> ### ** Examples
> 
> # Simulate wide data set for two subjects
> id <- as.numeric(c(1, 2))
> a_0 <- as.numeric(c(0, 1))
> a_1 <- as.numeric(c(1, 1))
> a_2 <- as.numeric(c(1, 0))
> l_0 <- as.numeric(rbinom(2, 1, 0.5))
> l_1 <- as.numeric(rbinom(2, 1, 0.5))
> l_2 <- as.numeric(rbinom(2, 1, 0.5))
> m_0 <- as.numeric(rbinom(2, 1, 0.5))
> m_1 <- as.numeric(rbinom(2, 1, 0.5))
> m_2 <- as.numeric(rbinom(2, 1, 0.5))
> n_0 <- as.numeric(rbinom(2, 1, 0.5))
> n_1 <- as.numeric(rbinom(2, 1, 0.5))
> n_2 <- as.numeric(rbinom(2, 1, 0.5))
> 
> mydata.wide <- data.frame(id, a_0, a_1, a_2,
+                           l_0, l_1, l_2,
+                           m_0, m_1, m_2,
+                           n_0, n_1, n_2)
> 
> # Run the makehistory.one() function
> mydata.history <- makehistory.one(input=mydata.wide,
+                                  id="id",
+                                   times=c(0,1,2),
+                                   exposure="a",
+                                   name.history="h"
+                                   )
Error in `mutate()`:
ℹ In argument: `his.lag = if_else(...)`.
ℹ In group 1: `ID = 1`.
Caused by error in `nth()`:
! Can't convert `default` <character> to match type of `x` <double>.
Backtrace:
     ▆
  1. ├─confoundr::makehistory.one(...)
  2. │ └─... %>% spread(.data$his.name.time, .data$his.value)
  3. ├─tidyr::spread(., .data$his.name.time, .data$his.value)
  4. ├─tidyr::unite(...)
  5. ├─dplyr::select(., .data$ID, c("his.name", "his.time", "his.value"))
  6. ├─dplyr::mutate(...)
  7. ├─dplyr:::mutate.data.frame(...)
  8. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
  9. │   ├─base::withCallingHandlers(...)
 10. │   └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
 11. │     └─mask$eval_all_mutate(quo)
 12. │       └─dplyr (local) eval()
 13. ├─dplyr::if_else(...)
 14. │ └─vctrs::vec_assert(x = condition, ptype = logical(), arg = "condition")
 15. │   └─vctrs:::vec_is_vector(x)
 16. ├─dplyr::first(.data$his.time, default = "NA")
 17. │ └─dplyr::nth(x, 1L, order_by = order_by, default = default, na_rm = na_rm)
 18. │   └─dplyr:::check_nth_default(default, x = x)
 19. │     └─vctrs::vec_cast(...)
 20. └─vctrs (local) `<fn>`()
 21.   └─vctrs::vec_default_cast(...)
 22.     ├─base::withRestarts(...)
 23.     │ └─base (local) withOneRestart(expr, restarts[[1L]])
 24.     │   └─base (local) doWithOneRestart(return(expr), restart)
 25.     └─vctrs::stop_incompatible_cast(...)
 26.       └─vctrs::stop_incompatible_type(...)
 27.         └─vctrs:::stop_incompatible(...)
 28.           └─vctrs:::stop_vctrs(...)
 29.             └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = vctrs_error_call(call))
Execution halted