#' @title htmlreg_convert
#'
#' @description This function converts a .docx file (created using texreg's htmlreg function) to a tabular file (excel or csv)
#' @param doc The .docx file
#' @param excel_format write whether you want this as "csv" or "xlsx"
#' @export
#' @return writes the output as a table in excel or csv format.
#'
htmlreg_convert<-function(doc,excel_format){
NAME1<-gsub(".docx",".xlsx",doc)
NAME2<-gsub(".docx",".csv",doc)
complx <- docxtractr::read_docx(doc) #Read .doc created using htmlreg
TABLE_XLS<-docxtractr::docx_extract_tbl(complx, 1, header=TRUE)
if (excel_format!="csv"){
openxlsx::write.xlsx(TABLE_XLS,NAME1)
}else {readr::write_csv(TABLE_XLS,NAME2)}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.