1 year ago
#259045
ecology
Making tables with Kable, issues with phantomJS install and ghostscript
I want to make tables with Kable, but I am unable to successfully install phantomJS. I found no detailed/helpful articles on this. The code below is what I have used on a MAC OSx computer to make the tables. Is error after I try to make the table due to no phantomJS installed?
Load packages and make dataframe
library(kableExtra)
library(magick)
library(webshot)
library(phantomJS)
Error in library(phantomJS) : there is no package called ‘phantomJS’
df <- data.frame(a=seq(1,16,by=2),b=LETTERS[1:8],x=month.abb[1:8],y=sample(10:20,8,replace=T),z=letters[1:8])
Now the code for table creation
kable(df, "latex", booktabs = T) %>%
kable_styling(latex_options = c("solid", "scale_down")) %>%
as_image() %>%
save_kable(file="table.pdf")
Error in save_kable_latex(x, file, latex_header_includes, keep_tex, density) :
We hit an error when trying to use magick to read the generated PDF file. You may check your magick installation and try to use magick::image_read to read the PDF file manually. It's also possible that you didn't have ghostscript installed.
install phantom w
ebshot::install_phantomjs(force = T)
trying URL 'https://github.com/wch/webshot/releases/download/v0.3.1/phantomjs-2.1.1-windows.zip'
Content type 'application/octet-stream' length 18193653 bytes (17.4 MB)
downloaded 17.4 MB
phantomjs has been installed to C:\Users\user1\AppData\Roaming\PhantomJS
> library(phantomJS)
Error in library(phantomJS) : there is no package called ‘phantomJS’
install.packages("phantomjs")
Installing package into ‘C:/Users/user1/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘phantomjs’ is not available for this version of R
r
phantomjs
kable
kableextra
0 Answers
Your Answer