gorkang / html2latex Goto Github PK
View Code? Open in Web Editor NEWConvert sjPlot::tab_model() html tables to tex and pdf
License: Other
Convert sjPlot::tab_model() html tables to tex and pdf
License: Other
The default branch of this repository is being moved from master
to main
. This issue will be closed when the default branch has been changed.
For help and guidance with updating the default branch of your local or forked copy of this repo, please see Renaming the default branch.
Search for files that may potentially reference master
.
ID: 91e77a361e4e
system2(soffice, paste0("--convert-to odt ", filename))
Need to have Java installed (e.g. https://www.java.com/en/download/manual.jsp)
system2("PATH\w2l.bat", "temp.odt")
source("R/html2pdf.R")
html2pdf(filename = "temp.html", page_width = 13, build_pdf = TRUE, silent = TRUE)
It seems a table label doesn't work after manually adding \label in temp.tex.
I'm having the same issue as the previous issue (that has since been closed), but installing LibreOffice has not solved it. The full error is:
Error in system(paste(soffice, "--convert-to odt", filename), intern = TRUE) :
'soffice' not found
If I modify the function and use the Mac = TRUE option to force soffice to point to the file path location on my PC (C:/Program Files/LibreOffice/program/soffice.exe), it gives a different error:
Error in system(paste0(file.path(path_w2l, w2l_file), " ", odt_file), :
'C:/Users/[Username]/Documents/R/win-library/4.0/html2latex/extdata/w2l' not found
though w2l (and writer2latex.jar) are both in the listed directory.
I just implemented a simple OS detection with Sys.info()["sysname"]
and adapted the code to change the relevant bits depending on the OS detected.
@tjebo , I am not sure if I used the proper identifier for macOS (OS == "Darwin" | OS == "macOS"), and I have no way to test it. If you could install the latest version remotes::install_github("gorkang/html2latex")
and give it a try, it would be awesome.
Seems to work fine on Linux and Windows.
A latex file temp.tex can be generated as follows. However, the file doesn't have label, which should be quite useful in a latex file.
'''
library(html2latex)
library(lme4)
library(sjPlot)
model = lmer(mpg ~ cyl * disp + (1|vs), mtcars)
TAB = sjPlot::tab_model(
model,
show.r2 = TRUE,
show.icc = FALSE,
show.re.var = FALSE,
p.style = "scientific",
emph.p = TRUE,
file = "temp.html")
html2pdf(filename = "temp.html",
table_width = 13,
silent = TRUE,
style = TRUE,
build_pdf = TRUE,
clean = TRUE)
'''
Trying to run the example given in the README,
just replacing lmer by lm for convenience.
OS is MacOS Big Sure Version 11.3 Beta
model = lm(mpg ~ cyl * disp + (1|vs), mtcars)
# We save the sjPlot table to an .html file
sjPlot::tab_model(
model,
show.r2 = TRUE,
show.icc = FALSE,
show.re.var = FALSE,
p.style = "scientific",
emph.p = TRUE,
file = "temp.html")
library(html2latex)
# Create tex and pdf
html2pdf(filename = "temp.html",
table_width = 13,
silent = TRUE,
style = TRUE,
build_pdf = TRUE,
clean = TRUE)
This throws the following error:
sh: soffice: command not found
Error in system(paste(soffice, "--convert-to odt", filename), intern = TRUE) :
error in running command
From the tutorial on Windows
TAB = sjPlot::tab_model(
model,
show.r2 = TRUE,
show.icc = FALSE,
show.re.var = FALSE,
p.style = "scientific",
emph.p = TRUE,
file = "temp.html") doesnt generate the html, only when its not assigned.
Is that on purpose?
Hi
thx for this. I just wanted to flag that on Windows the Tex conversion didn't like it when there was spaces on the path leading to the table. The ODT could however cope with it.
For collapse.se=TRUE or collapse.ci=TRUE in sjPlot::tab_model(), the tex output of html2pdf() does not show the collapsed statistics in separate rows.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.