schmidtchristoph / js2graphic

R package for saving JavaScript generated plots as graphics file
MIT License
5 stars 0 forks source link

I meet some error during the example code #3

Closed BioAIEvolu closed 4 years ago

BioAIEvolu commented 4 years ago

I meet some error during the example code.Are some dependency packages needed to be installed?

> path1 <- system.file("Express_web_summary.html", package = "js2graphic")
> setwd('C:\\Users\\Administrator\\Desktop\\')
> path1 <- "Express_web_summary.html"
> jsGraphic2Pdf("/Express_web_summary.html", c(950, 500, 40, 20)) # stores the JS graphic as pdf
> pdfcrop("JSgraphic.pdf") # generates the final cropped pdf containing the JS generated plot
Error in pdfcrop("JSgraphic.pdf") : 
  The file corresponding to input argument 'fileName' does not exist.
> setwd('C:\\Users\\Administrator\\Desktop\\')
> path1 <- "Express_web_summary.html"
> jsGraphic2Pdf("/Express_web_summary.html", c(950, 500, 40, 20)) # stores the JS graphic as pdf
> pdfcrop("JSgraphic.pdf") # generates the final cropped pdf containing the JS generated plot
Error in pdfcrop("JSgraphic.pdf") : 
  The file corresponding to input argument 'fileName' does not exist.
> jsGraphic2Pdf("Express_web_summary.html", c(950, 500, 40, 20)) # stores the JS graphic as pdf
> pdfcrop("JSgraphic.pdf") # generates the final cropped pdf containing the JS generated plot
Error in pdfcrop("JSgraphic.pdf") : 
  The file corresponding to input argument 'fileName' does not exist.
> ?jsGraphic2Pdf
> path1 <- system.file("extdata/alplots2_ff.html", package = "js2graphic")
> path1
[1] "D:/R-3.6.1/library/js2graphic/extdata/alplots2_ff.html"
> path1 <- system.file("extdata/alplots2_ff.html", package = "js2graphic")
> file.copy(path1, getwd())
[1] TRUE
> path1
[1] "D:/R-3.6.1/library/js2graphic/extdata/alplots2_ff.html"
> jsGraphic2Pdf("alplots2_ff.html", c(950, 500, 40, 20)) # stores the JS graphic as pdf
> pdfcrop("JSgraphic.pdf") # generates the final cropped pdf containing the JS generated plot
Error in pdfcrop("JSgraphic.pdf") : 
  The file corresponding to input argument 'fileName' does not exist.
> pdfcrop("JSgraphic.pdf") # generates the final cropped pdf containing the JS generated plot
Error in pdfcrop("JSgraphic.pdf") : 
  The file corresponding to input argument 'fileName' does not exist.
> jsGraphic2Png(file, c(950, 500, 40, 20)) # stores the JS graphic as png
Error: object of type 'closure' is not subsettable
> imagecrop("JSgraphic.png") # generates the final cropped png containing the JS generated plot
Error in imagecrop("JSgraphic.png") : 
  The file corresponding to input argument 'fileName' does not exist.
> file.remove(c("alplots2_ff.html", "JSgraphic.pdf", "JSgraphic_cr.pdf", "JSgraphic.png", "JSgraphic_cr.png")) # remove all files after inspecting the final pdf and png
[1]  TRUE FALSE FALSE FALSE FALSE
Warning messages:
1: In file.remove(c("alplots2_ff.html", "JSgraphic.pdf", "JSgraphic_cr.pdf",  :
  cannot remove file 'JSgraphic.pdf', reason 'No such file or directory'
2: In file.remove(c("alplots2_ff.html", "JSgraphic.pdf", "JSgraphic_cr.pdf",  :
  cannot remove file 'JSgraphic_cr.pdf', reason 'No such file or directory'
3: In file.remove(c("alplots2_ff.html", "JSgraphic.pdf", "JSgraphic_cr.pdf",  :
  cannot remove file 'JSgraphic.png', reason 'No such file or directory'
4: In file.remove(c("alplots2_ff.html", "JSgraphic.pdf", "JSgraphic_cr.pdf",  :
  cannot remove file 'JSgraphic_cr.png', reason 'No such file or directory'
schmidtchristoph commented 4 years ago

Hi @BioAIEvolu ,

I just looked at your issue. First, the code you posted is not a minimal working example so I cannot reproduce your problem. Also, it is not exactly the code from the examples in my documentation.

You should make sure that the path argument for e.g. jsGraphic2Pdf is correct. On the first line you refer to an file outside of my package data. Hence, no path is returned for path1.

As to your second question. System dependencies are listed at the end of the README.md file as well as in the packaged DESCRIPTION file.

By the way, your second line of code suggests that your logged into your computer as admin, which is probably not a good idea.

I hope this helps. I will close the issue for now. Please reopen it or let me know if your issue persists with a correct file path argument.

Regards, Christoph