Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

star_rhs_names doesn't use regex when the pattern ends with $ #11

Open
ChandlerLutz opened this issue Nov 25, 2018 · 0 comments
Open

star_rhs_names doesn't use regex when the pattern ends with $ #11

ChandlerLutz opened this issue Nov 25, 2018 · 0 comments

Comments

@ChandlerLutz
Copy link
Owner

See this example

library(stargazer); library(starpolishr); library(magrittr)

star.out <- c("", "% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu", 
"% Date and time: Sun, Nov 25, 2018 - 10:58:01 AM", "\\begin{table}[!htbp] \\centering ", 
"  \\caption{\\textbf{The Impact of the CFPLs on Foreclosure Maintenance and Repair Costs -- Non-Judicial States}} ", 
"  \\label{tab:reg_forc_costs_non_judicial} ", "\\begin{tabular}{@{\\extracolsep{5pt}}lccccccc} ", 
"\\\\[-1.8ex]\\hline ", "\\hline \\\\[-1.8ex] ", " & \\multicolumn{7}{c}{\\textit{Dependent variable:}} \\\\ ", 
"\\cline{2-8} ", "\\\\[-1.8ex] & \\multicolumn{7}{c}{Foreclosure Maintenance and Repair Costs} \\\\ ", 
"\\\\[-1.8ex] & (1) & (2) & (3) & (4) & (5) & (6) & (7)\\\\ ", 
"\\hline \\\\[-1.8ex] ", " CA & $-$57.887 & 169.838 & 187.892 &  &  &  &  \\\\ ", 
"  & (164.887) & (176.247) & (159.774) &  &  &  &  \\\\ ", "  & & & & & & & \\\\ ", 
" CFPL & 478.728$^{}$ & 229.776$^{}$ &  &  &  &  &  \\\\ ", "  & (93.628) & (87.030) &  &  &  &  &  \\\\ ", 
"  & & & & & & & \\\\ ", " CA.CFPL & 573.777$^{}$ & 493.146$^{}$ & 471.543$^{}$ & 314.882$^{}$ & 411.657$^{}$ & 946.176$^{}$ & 917.492$^{}$ \\\\ ", 
"  & (163.500) & (134.201) & (123.034) & (109.373) & (116.058) & (416.403) & (467.139) \\\\ ", 
"  & & & & & & & \\\\ ", " months.in.reo.forc &  & 314.932$^{}$ & 324.301$^{}$ & 412.341$^{}$ & 411.199$^{}$ & 420.230$^{}$ & 423.470$^{}$ \\\\ ", 
"  &  & (28.429) & (27.554) & (33.895) & (33.236) & (35.868) & (36.320) \\\\ ", 
"  & & & & & & & \\\\ ", " months.in.reo.forc2 &  & $-$3.091$^{}$ & $-$3.356$^{}$ & $-$5.222$^{}$ & $-$5.361$^{}$ & $-$5.683$^{}$ & $-$5.709$^{}$ \\\\ ", 
"  &  & (1.238) & (1.215) & (1.306) & (1.316) & (1.412) & (1.428) \\\\ ", 
"  & & & & & & & \\\\ ", " Constant & 3,016.112$^{}$ & 1,007.346$^{}$ &  &  &  &  &  \\\\ ", 
"  & (132.352) & (159.897) &  &  &  &  &  \\\\ ", "  & & & & & & & \\\\ ", 
"\\hline \\\\[-1.8ex] ", "Observations & 31,056 & 31,056 & 31,056 & 31,056 & 31,056 & 31,056 & 31,056 \\\\ ", 
"\\hline ", "\\hline \\\\[-1.8ex] ", "\\textit{Note:}  & \\multicolumn{7}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\\\ ", 
"\\end{tabular} ", "\\end{table} ")

star.out <- star.out %>% star_rhs_names(pattern = c("CA.CFPL", "months.in.reo.forc$", "months.in.reo.forc2$"),
                 line1 = c("CA $\\\\times$ CFPL", "Months in REO", "Months in REO"),
                 line2 = c("", "Foreclosure", "Foreclosure\\$^2\\$")
                 )

print(star.out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant