[go: up one dir, main page]

File: checkdir.R

package info (click to toggle)
r-cran-statcheck 1.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 228 kB
  • sloc: makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,194 bytes parent folder | download
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
44
45
46
47
48
49
50
51
checkdir <-
  function(dir, subdir = TRUE, ...) {
    if (missing(dir))
      dir <- tk_choose.dir()
    
    pdfs <-
      any(grepl("\\.pdf$", list.files(dir, recursive = subdir), ignore.case =
                  TRUE))
    htmls <-
      any(grepl(
        "\\.html?$",
        list.files(dir, recursive = subdir),
        ignore.case = TRUE
      ))
    
    if (pdfs)
      pdfres <- checkPDFdir(dir, ...)
    if (htmls)
      htmlres <- checkHTMLdir(dir, ...)
    
    if (pdfs & htmls) {
      if (!is.null(pdfres) & !is.null(htmlres))
        Res <- rbind(pdfres, htmlres)
      else
        stop("statcheck did not find any results")
      
    } else
      if (pdfs & !htmls) {
        if (!is.null(pdfres))
          Res <- pdfres
        else
          stop("statcheck did not find any results")
      }
    
    else
      if (!pdfs & htmls) {
        if (!is.null(htmlres))
          Res <- htmlres
        else
          stop("statcheck did not find any results")
      }
    
    else
      if (!pdfs & !htmls)
        stop("No PDF or HTML found")
    
    
    class(Res) <- c("statcheck", "data.frame")
    return(Res)
    
  }