Home:ALL Converter>Merge 1000 HTML files in R

Merge 1000 HTML files in R

Ask Time:2018-06-08T21:54:22         Author:user15051990

Json Formatter

I have more than 1000 html files and I want to merge them together. I have provided the code below how I am doing it. But it's not getting merge and I am getting blank html file(merged).

saveWidget(f1, "f1.html")
saveWidget(f2, "f2.html")
saveWidget(f3, "f3.html")
saveWidget(f4, "f4.html") and so on till saveWidget(f1000, "f1000.html")

Code to merge files:

    library(htmlwidgets)
    htmlFiles<-list.files("/path/")
    library(htmltools)
    widgets <- list(htmlFiles)
    #fns <- replicate(length(widgets), tempfile(pattern = "widget_", fileext = #".html"))
    #Map(htmlwidgets::saveWidget, widgets, fns)

iframes <- lapply(widgets, function(fn) 
  tags$iframe(
    src = paste0("/path/", fn), 
    style="display:block", 
    height="300", width="1200"
  )  
)
tags$html(
  tags$body(
    iframes
  )
) %>% 
  save_html(tf<<-tempfile(fileext = ".html"))
shell.exec(tf)

Thanks in advance!

Author:user15051990,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50762229/merge-1000-html-files-in-r
yy