简体   繁体   中英

How to append notes to a latex table in Hmisc in R?

An unelegant way is just to add lines of tex code with the note text.

But is there a more native way of making notes in latex function of Hmisc package in R?

There is a way not in Hmisc but using starpolishr package,

install.packages("devtools")
library(devtools)
install_github("ChandlerLutz/starpolishr");library(starpolishr)

Insert footnotes with caption package

la<-latex(mtcars[1:2,1:5],file="example.tex",caption = "table using caption",
    where="!htbp") 
file0<-readLines("example.tex") 
file0<-star_notes_tex(file0, note = "file using caption*") 
cat(file0, file = paste0(getwd(),"/file0.tex"),sep="\n")

Insert footnotes with threeparttable

Attention, you must use the caption and label argument in Hmisc::latex

mt <- mtcars[1:2,1:5]
mt[1,1]<-paste0(mt[1,1],"\\tnote{*}")
la<-latex(mt,file="example1.tex",label=" ",caption="table using threeparttable",
    where="!htbp") 
file1<-readLines("example1.tex") 
file1<-star_notes_tex(file1, note.type = "threeparttable",
note = "* notes with threeparttable : For this example you must use both label and caption, the
 threepartable code is meant to be used with tables generated by
 stargazer where a row with label is present. Otherwise the threepart table 
 argument is badly positionned.")
cat(file1, file = paste0(getwd(),"/file1.tex"),sep="\n")

脚注

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM