Showing 2 of 2 files from the diff.

@@ -1,13 +1,13 @@
Loading
1 1
#' Logistic regression report
2 2
#'
3 -
#' Generate detailed logistic regression report. 
3 +
#' Generate detailed logistic regression report.
4 4
#'
5 5
#' @param use_yaml Use YAML file to specify report details.
6 6
#'
7 7
#' @examples
8 8
#' \dontrun{
9 9
#' model_data <- blorr::bank_marketing
10 -
#' 
10 +
#'
11 11
#' # interactive
12 12
#' report_blr()
13 13
#'
@@ -23,19 +23,37 @@
Loading
23 23
24 24
  if (use_yaml) {
25 25
    copy_yaml("logistic")
26 +
26 27
    file.edit(glue(here(), "/_logistic.yml"))
27 -
    cat(glue('Please update the report details in the ', green('_logistic.yml'), ' file.'), "\n\n")
28 -
    sleep_time <- showPrompt("Update Time", "Specify the time required in seconds to update the YAML file?", 30)
28 +
29 +
    cat(
30 +
      glue('Please update the report details in the ',
31 +
           green('_logistic.yml'),
32 +
           ' file.'
33 +
      ), "\n\n")
34 +
35 +
    sleep_time <- showPrompt(
36 +
      title   = "Update Time",
37 +
      message = "Specify the time required in seconds to update the YAML file?",
38 +
      default = 30)
39 +
29 40
    Sys.sleep(sleep_time)
30 -
    update_status <- showQuestion("File Status", "Have you updated the yaml file?", 
31 -
                         "Yes", "No")
41 +
42 +
    update_status <- showQuestion(
43 +
      title   = "File Status",
44 +
      message = "Have you updated the yaml file?",
45 +
      ok      = "Yes",
46 +
      cancel  ="No")
47 +
32 48
    documentSaveAll()
49 +
33 50
    if (update_status) {
34 -
      logistic_yaml <- read_yaml(glue(here(), "/_logistic.yml"))  
51 +
      logistic_yaml <- read_yaml(glue(here(), "/_logistic.yml"))
35 52
    } else {
36 -
      stop("Please update the YAML file with the report details.", call. = FALSE)
53 +
      stop("Please update the YAML file with the report details.",
54 +
           call. = FALSE)
37 55
    }
38 -
    
56 +
39 57
  }
40 58
41 59
  if (use_yaml) {
@@ -57,39 +75,69 @@
Loading
57 75
    report_date   <- ask_date()
58 76
    data_name     <- ask_data_name()
59 77
    model_formula <- ask_model()
60 -
    document_type <- ask_type() 
78 +
    document_type <- ask_type()
61 79
    } else {
62 80
      stop("RStudio must be installed.", call. = FALSE)
63 81
    }
64 -
    
82 +
65 83
  }
66 84
67 85
  # prep report folders and file
68 -
  cat(blue$bold(symbol$tick), glue('Creating ', green("'"), green(folder_name), 
69 -
                                 green("'"), ' folder'), '\n')
86 +
  cat(blue$bold(symbol$tick),
87 +
      glue('Creating ',
88 +
           green("'"),
89 +
           green(folder_name),
90 +
           green("'"),
91 +
           ' folder'
92 +
      ), '\n')
93 +
70 94
  dir_create(folder_name)
95 +
71 96
  if (use_yaml) {
72 97
    Sys.sleep(2)
73 -
    cat(blue$bold(symbol$tick), glue('Moving ', green("'_logistic.yml'"), ' file to ', folder_name), '\n')
74 -
    file_move(glue(here(), "/_logistic.yml"), glue(here(), "/", folder_name, "/_logistic.yml"))
98 +
99 +
    cat(blue$bold(symbol$tick),
100 +
        glue('Moving ',
101 +
             green("'_logistic.yml'"),
102 +
             ' file to ',
103 +
             folder_name
104 +
        ), '\n')
105 +
106 +
    file_move(glue(here(), "/_logistic.yml"),
107 +
              glue(here(), "/", folder_name, "/_logistic.yml"))
75 108
  }
76 109
77 110
  # add .Rmd extension to file_name
78 111
  report_file <- add_ext(folder_name, file_name)
112 +
79 113
  Sys.sleep(2)
80 -
  cat(blue$bold(symbol$tick), glue('Creating ', green("'"), green(file_name), 
81 -
                                 green("'"), ' file'), '\n')
114 +
115 +
  cat(blue$bold(symbol$tick),
116 +
      glue('Creating ',
117 +
           green("'"),
118 +
           green(file_name),
119 +
           green("'"),
120 +
           ' file'
121 +
      ), '\n')
122 +
82 123
  file_create(report_file)
83 124
84 125
  # copy template from inst folder
85 126
  Sys.sleep(2)
86 -
  cat(blue$bold(symbol$tick), glue('Copying report template into ', green("'"), green(folder_name), 
87 -
                                 green("'"), ' folder'), '\n')
127 +
128 +
  cat(blue$bold(symbol$tick),
129 +
      glue('Copying report template into ',
130 +
           green("'"),
131 +
           green(folder_name),
132 +
           green("'"),
133 +
           ' folder'
134 +
      ), '\n')
135 +
88 136
  copy_template(folder_name, "blorr_template")
89 137
90 138
  # add yaml
91 139
  Sys.sleep(2)
92 -
  cat(blue$bold(symbol$tick), glue('Adding YAML to ', green("'"), green(file_name), 
140 +
  cat(blue$bold(symbol$tick), glue('Adding YAML to ', green("'"), green(file_name),
93 141
                                 green("'"), ' file'), '\n')
94 142
  cat('---\n', file = report_file, append =FALSE)
95 143
  cat(glue('title: "', {report_title}, '"', '\n\n'), file = report_file,
@@ -121,19 +169,40 @@
Loading
121 169
122 170
  # load data
123 171
  Sys.sleep(2)
124 -
  cat(blue$bold(symbol$tick), glue('Loading data ', green("'"), green(data_name), 
125 -
                                 green("'")), '\n')
172 +
173 +
  cat(blue$bold(symbol$tick),
174 +
      glue('Loading data ',
175 +
           green("'"),
176 +
           green(data_name),
177 +
           green("'")
178 +
      ), '\n')
179 +
126 180
  prep_data(data_name)
127 181
128 182
  # build and view report
129 183
  Sys.sleep(2)
130 -
  cat(blue$bold(symbol$tick), glue('Generating ', green("'"), green(report_title), 
131 -
                                 green("'")), '\n')
184 +
185 +
  cat(blue$bold(symbol$tick),
186 +
      glue('Generating ',
187 +
           green("'"),
188 +
           green(report_title),
189 +
           green("'")
190 +
      ), '\n')
191 +
132 192
  render(report_file, quiet = TRUE)
193 +
133 194
  report_name <- glue(folder_name, "/", file_name, ".", document_type)
195 +
134 196
  Sys.sleep(2)
135 -
  cat(blue$bold(symbol$tick), glue('Opening ', green("'"), green(report_title), 
136 -
                                 green("'"), ' in default browser'), '\n')
197 +
198 +
  cat(blue$bold(symbol$tick),
199 +
      glue('Opening ',
200 +
           green("'"),
201 +
           green(report_title),
202 +
           green("'"),
203 +
           ' in default browser'
204 +
      ), '\n')
205 +
137 206
  browseURL(report_name)
138 207
139 208
}

@@ -1,12 +1,12 @@
Loading
1 1
#' @importFrom rstudioapi showPrompt
2 2
ask_folder_name <- function() {
3 -
  showPrompt(title = "Folder Title",
4 -
                           message = "Title of the Folder",
5 -
                           default = "report")
3 +
  showPrompt(title   = "Folder Title",
4 +
             message = "Title of the Folder",
5 +
             default = "report")
6 6
}
7 7
8 8
ask_file_name <- function() {
9 -
  showPrompt(title = "File Title",
9 +
  showPrompt(  title = "File Title",
10 10
             message = "Title of the File",
11 11
             default = "report")
12 12
}
@@ -19,38 +19,38 @@
Loading
19 19
#' @importFrom fs file_copy file_exists
20 20
#' @importFrom here here
21 21
copy_template <- function(folder_name, template_name) {
22 -
  pkg_loc <- find.package("report")
22 +
  pkg_loc       <- find.package("report")
23 23
  template_path <- glue(pkg_loc, '/templates/', template_name, '.Rmd')
24 -
  report_path <- glue(here(), "/", folder_name, "/", template_name, ".Rmd")
24 +
  report_path   <- glue(here(), "/", folder_name, "/", template_name, ".Rmd")
25 25
  if (!file_exists(report_path)) {
26 26
    file_copy(template_path, report_path)
27 27
  }
28 28
}
29 29
30 30
copy_yaml <- function(yaml_name) {
31 -
  pkg_loc <- find.package("report")
31 +
  pkg_loc       <- find.package("report")
32 32
  template_path <- glue(pkg_loc, '/yaml/_', yaml_name, '.yml')
33 -
  report_path <- glue(here(), "/_", yaml_name, ".yml")
33 +
  report_path   <- glue(here(), "/_", yaml_name, ".yml")
34 34
  if (!file_exists(report_path)) {
35 35
    file_copy(template_path, report_path)
36 36
  }
37 37
}
38 38
39 39
ask_title <- function() {
40 -
  showPrompt(title = "Report Title",
40 +
  showPrompt(title   = "Report Title",
41 41
             message = "Title of the Report",
42 42
             default = "report")
43 43
}
44 44
45 45
ask_author <- function() {
46 -
  showPrompt(title = "Report Author",
46 +
  showPrompt(title   = "Report Author",
47 47
             message = "Author of the Report",
48 48
             default = NULL)
49 49
}
50 50
51 51
#' @importFrom lubridate today
52 52
ask_date <- function() {
53 -
  showPrompt(title = "Report Date",
53 +
  showPrompt(title   = "Report Date",
54 54
             message = "Date of the Report",
55 55
             default = as.character(today()))
56 56
}
@@ -62,7 +62,7 @@
Loading
62 62
}
63 63
64 64
ask_type <- function() {
65 -
  showPrompt(title = "Document Type",
65 +
  showPrompt(title   = "Document Type",
66 66
             message = "Specify the document type (pdf or html)",
67 67
             default = "html")
68 68
}
@@ -72,37 +72,37 @@
Loading
72 72
}
73 73
74 74
ask_data_name <- function() {
75 -
  showPrompt(title = "Data Name",
75 +
  showPrompt(title   = "Data Name",
76 76
             message = "Specify the name of the data set",
77 77
             default = NULL)
78 78
}
79 79
80 80
ask_analysis_date <- function() {
81 -
  showPrompt(title = "Analysis Date",
81 +
  showPrompt(title   = "Analysis Date",
82 82
             message = "Specify the date of analysis",
83 83
             default = as.character(today()))
84 84
}
85 85
86 86
ask_customer_id <- function() {
87 -
  showPrompt(title = "Customer ID",
87 +
  showPrompt(title   = "Customer ID",
88 88
             message = "Specify the name of the column to identify customer id",
89 -
             default = "customer_id")  
89 +
             default = "customer_id")
90 90
}
91 91
92 92
ask_order_date <- function() {
93 -
  showPrompt(title = "Order Date",
93 +
  showPrompt(title   = "Order Date",
94 94
             message = "Specify the name of the column to identify order date",
95 -
             default = "order_date")  
95 +
             default = "order_date")
96 96
}
97 97
98 98
ask_revenue <- function() {
99 -
  showPrompt(title = "Revenue",
99 +
  showPrompt(title   = "Revenue",
100 100
             message = "Specify the name of the column to identify revenue",
101 -
             default = "revenue")  
101 +
             default = "revenue")
102 102
}
103 103
104 104
105 105
prep_data <- function(mydata) {
106 106
  save(mydata, file = glue(mydata, ".RData"))
107 107
  load(glue(here(), '/', mydata, '.RData'))
108 -
}
Files Coverage
R 0.00%
Project Totals (6 files) 0.00%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading