Shiny에서 rPivotTable의 스크린 샷 이미지를 얻으려고합니다. htmlwidgets에서 saveWidget()을 사용하여 rpivottable을 저장하고 있습니다. 그런 다음 html을 jpeg 이미지로 변환하기 위해 webshot()을 사용하려고합니다. saveWidget에서 생성 된 html이 Firefox에서는 올바르게 표시되지만 webshot에서 생성 된 이미지는 비어 있습니다. 나는 webshot에서 생성 된 이미지를 첨부했습니다. 다음은 R Webshot jpeg 이미지가 비어 있습니다.
내가 나는 여전히 출력으로 단지 빈 이미지를 얻고 How to save Leaflet in RStudio map as png or jpg file? 에서 솔루션 중 하나를 사용하려고 내가
library(rpivotTable)
library(htmlwidgets)
library(webshot)
mypivot <- rpivotTable(mtcars, rows = "cyl", cols = "mpg")
saveWidget(mypivot, "myPivot.html", selfcontained = FALSE)
webshot(url = "myPivot.html", file = "myPivot.jpeg")
함께 일하고 샘플 코드입니다. 아래는 생성 된 이미지입니다 (완전히 흰색입니다).
아래 코드는 제가 사용하고있는 코드입니다.
library(leaflet)
library(htmlwidgets)
library(webshot)
## create map
m <- leaflet() %>% addTiles()
## save html to png
saveWidget(m, "temp.html", selfcontained = FALSE)
webshot("temp.html", file = "Rplot.png",
cliprect = "viewport")
다음은 내 R 세션에 대한 정보입니다. 나는 RStudio를 사용하고있다.
R> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[2] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[2] stats graphics grDevices utils datasets methods base
other attached packages:
[2] rpivotTable_0.1.5.20 htmlwidgets_0.6 mapview_1.1.0 leaflet_1.0.1 webshot_0.3 htmltools_0.3.5
loaded via a namespace (and not attached):
[2] Rcpp_0.12.5 RColorBrewer_1.1-2 plyr_1.8.4 R.methodsS3_1.7.1 R.utils_2.3.0 viridis_0.3.4 base64enc_0.1-3
[8] iterators_1.0.8 tools_3.2.2 gdalUtils_2.0.1.7 digest_0.6.9 viridisLite_0.1.3 satellite_0.2.0 lattice_0.20-33
[15] jsonlite_0.9.22 gtable_0.2.0 png_0.1-7 foreach_1.4.3 shiny_0.13.2 DBI_0.4-1 yaml_2.1.13
[22] rgdal_1.1-10 parallel_3.2.2 gridExtra_2.2.1 dplyr_0.4.3 httr_1.1.0 raster_2.5-8 stats4_3.2.2
[29] grid_3.2.2 R6_2.1.2 plotly_3.6.0 sp_1.2-3 latticeExtra_0.6-28 tidyr_0.4.1 ggplot2_2.1.0
[36] magrittr_1.5 scales_0.4.0 codetools_0.2-14 assertthat_0.1 mime_0.4 xtable_1.8-2 colorspace_1.2-6
[43] httpuv_1.3.3 munsell_0.4.3 R.oo_1.20.0