It seems reasonable that id should be able to be a character vector. This same error will occur when the 'trt_time' refers to a character vector, and I think that a warning should be thrown there.
library(rsmatch)
df <- data.frame(
hhidpn = rep(1:3, each = 3),
wave = rep(1:3, 3),
treatment_time = rep(c(2,3,NA), each = 3),
X1 = c(2,2,2,3,3,3,9,9,9),
X2 = rep(c("a","a","b"), each = 3),
X3 = c(9,4,5,6,7,2,3,4,8),
X4 = c(8,9,4,5,6,7,2,3,4)
)
df$hhidpn <- as.character(df$hhidpn)
pairs <- brsmatch(n_pairs = 1, df = df, id = "hhidpn", time = "wave", trt_time = "treatment_time",
optimizer = "glpk", options = "between period treatment")
#> Error in t(B_p) - t(B_e): non-numeric argument to binary operator
It seems reasonable that id should be able to be a character vector. This same error will occur when the 'trt_time' refers to a character vector, and I think that a warning should be thrown there.
Created on 2021-02-09 by the reprex package (v0.3.0)