Open grantmcdermott opened 2 years ago
One approach would be to use grep instead of match here. E.g.
grep
match
resampvar_pos = grep(resampvar, Xnames) ## CHANGED resampvar_orig = NULL if (length(resampvar_pos)==0) { ## CHANGED resampvar_orig = resampvar resampvar = paste0(resampvar, 1) resampvar_pos = grep(resampvar, Xnames) ## CHANGED ...
An additional advantage of grep is that it makes it easier to use regular expressions to glob a bunch of variables. E,g,
est = fixest::feols(y ~ x1 + i(period, treat, 5) | id+period, fixest::base_did) grep("^period", names(coefficients(est))) #> 2 3 4 5 6 7 8 9 10
One approach would be to use
grep
instead ofmatch
here. E.g.An additional advantage of
grep
is that it makes it easier to use regular expressions to glob a bunch of variables. E,g,