0

I am using texreg for regression output. I would like to align on decimals in the table. However, all numbers are in math mode, between '$' characters. Is there an option to only enclose the significance stars in '$', leaving the numbers as regular text?

1 Answers1

0

Used stringr to modify the output of texreg. For anyone interested:

tex <- texreg(list(model1,model2,model3,model4),
       digits = 3,
       stars=c(0.1,0.05,0.01,0.001),
       symbol='+')
#
# convert numbers to text, grabbing stars and keeping between math symbols.
library(stringr)
newTex <- str_replace_all(tex,"\\$\\(?-?\\d+(,\\d+)*(\\.\\d+(e\\d+)?)?\\)?\\^?\\{?(\\*+)?\\+?\\}?\\$",
                          function(x) {
                            if(str_detect(x,"\\^")) {
                              ret <- sub("^","$^",sub("$","",x,fixed=T),fixed=T)
                            } else {
                              ret <- gsub("$","",x,fixed=T)
                            }
                            return(ret)
                          })