I am running an lm regression in r, where there are categorical variables and numerical variables. I am usig knitr to compile the Rnw file to make a pdf. I use texreg to make latex regression tables. But when I do the compiling, it reported that lots of lines "Label `' multiply defined". Is it a must that we should assign label to each variable in the regression? But for those factor variables, I tried to assign label, like label(data$var) <- "name", then the warning is "label" command cannot be applied to the class of factor. Now I am really confused. Can anyone help me with this?
2 Answers
3
votes
A perl-bash snippet has been developed here:
perl -nE "say $1 if /(\\label[^}]*})/" *.tex | sort | uniq -c
which searches the .tex file for all \label{...}
s using the regular expression \\label[^}]*}
and then sot-group them by the number of occurance. Just fix the labels with more than 1 occurance (duplicated ones) and the warning should go away.
1
votes
You are using the texreg
package to create multiple tables for inclusion in a LaTeX document. When you use the texreg
function, a LaTeX table is created. But all tables have the same line:
\label{table:coefficients}
LaTeX complains that this same label was included multiple times, thus not allowing you to reference any specific table.
To remedy the situation, you can include the label
argument in your texreg calls as in the following example:
texreg(mymodel, label = "firsttable")
Make sure you change the label for each table.
\label{<something>}
more than once for the exact same<something>
inside your LaTeX code. – Werner