File: checkHTMLdir.R

package info (click to toggle)
r-cran-statcheck 1.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 764 kB
  • sloc: makefile: 2
file content (43 lines) | stat: -rw-r--r-- 909 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#' @rdname checkdirs
#' @export

checkHTMLdir <- function(dir,
                         subdir = TRUE,
                         extension = TRUE,
                         ...) {
  if (missing(dir)) {
    dir <- tcltk::tk_choose.dir()
  }
  
  if (extension == TRUE) {
    pat = ".html|.htm"
  }
  
  if (extension == FALSE) {
    pat = ""
  }
  
  files <-
    list.files(dir,
               pattern = pat,
               full.names = TRUE,
               recursive = subdir)
  
  if (length(files) == 0) {
    stop("No HTML found")
  }
  
  txts <- character(length(files))
  message("Importing HTML files...")
  pb <- utils::txtProgressBar(max = length(files), style = 3)
  
  for (i in 1:length(files)) {
    txts[i] <-  getHTML(files[i])
    utils::setTxtProgressBar(pb, i)
  }
  
  close(pb)
  
  names(txts) <- basename(files)
  return(statcheck(txts, ...))
}