6

によって作成されたテーブルの下部にかなり長いメモを追加しようとしていますtexreg。これを単純にラップアラウンドしたいのですが、そのための機能が関数に組み込まれているようには見えません。

たとえば、次のようにします。

texreg(
  lm(speed ~ dist, data = cars),
  custom.note = paste(
    "%stars. This regression should be",
    "intepreted with strong caution as",
    "it is likely plagued by extensive", 
    "omitted variable bias"
  )
)

コンパイルすると、次のようになります。

回帰のコンパイルされた TeX 出力。 脚注がすべて 1 行にあるため、1 列の結果が非常に広くなり、不要な空白が大量に発生します。

フォーマットはひどいものです。標準出力を置き換えるようなものの方がはるかに良いでしょう:

\multicolumn{2}{l}{\scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$. This regression should be intepreted with strong caution as it is likely plagued by extensive omitted variable bias}}

より消化しやすいラッピング:

\multicolumn{2}{l}{\scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$.}} \\
\multicolumn{2}{l}{\scriptsize{This regression should be intepreted with}} \\
\multicolumn{2}{l}{\scriptsize{strong caution as it is likely plagued by}} \\
\multicolumn{2}{l}{\scriptsize{extensive omitted variable bias}}

これにより、探しているものにはるかに近い出力が得られます。

現在、脚注は折り返されています。脚注の幅は、表全体の幅によって決まりますが、その逆ではありません。

これをプログラムで行う方法はありますか?

4

3 に答える 3

2

引数をtexreg追加して変更することで関数を書き直すことで、これまでのところ回避策を考え出しました。custom.note.wrap

note <- paste0("\\multicolumn{", length(models) + 1, 
               "}{l}{\\", notesize, "{", custom.note, "}}")
note <- gsub("%stars", snote, note, perl = TRUE)

に:

if (custom.note.wrap){
  note<-paste(paste0("\\multicolumn{", length(models) + 1L,"}{l}{\\",notesize,"{",
                     strwrap(custom.note, width=custom.note.wrap), "}}"),
              collapse = " \\ \n")
  note <- gsub("%stars", snote, note, perl = TRUE)
}else{
  note <- paste0("\\multicolumn{", length(models) + 1L, 
                 "}{l}{\\", notesize, "{", custom.note, "}}")
  note <- gsub("%stars", snote, note, perl = TRUE)
}

アイデアは、各行 ( custom.note.wrap) の最大文字列長を選択し、提供された音符をスペースで終わる最大でその長さの文字列に分割し、最終的にすべてを連結して、multicolumn分割された各部分文字列を持つ s の束にすることです。

これは、モデル名の長さなどを考慮texregして自動的に設定する方がよいため、最適ではありません。custom.note.wrapLaTeX

于 2015-06-17T22:37:07.713 に答える