Skip to content

Commit

Permalink
edit: tables and output display; need to update in real time
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleGrealis committed Jan 8, 2024
1 parent dcdb1cc commit 4f94c46
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions app/view/algo.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,33 @@ server <- function(id, newFile, inputs) {
ns <- session$ns

best_matched_data <- reactiveVal()

# for text output
rv <- reactiveValues(data = "")

observeEvent(inputs()$matchButton, {

rv$data <- paste(
rv$data, glue::glue(
"Beginning iterative matching process...
The algorithm will retain the iteration that produces the greatest number of matched cases.
------------------------------------------------------\n"
), sep = "\n"
)

best_matched_data(NULL)

# start computation timer
start_time <- proc.time()

# matching loop
for(i in 1:1) {
for(i in 1:3) {

# provide feedback to the user
print(glue::glue("Starting iteration {i}..."))
rv$data <- paste(
rv$data, glue::glue("Starting iteration {i}..."), sep = "\n"
)

# get the results of the best iteration
if (!is.null(best_matched_data())) {
Expand Down Expand Up @@ -75,11 +87,16 @@ server <- function(id, newFile, inputs) {
# provide feedback to the user
print(
glue::glue(
"\nIteration {i} produced {nrow(matched_data)} rows and
{match_results$n_cases} matched cases.
"\nIteration {i} produced {nrow(matched_data)} rows and {match_results$n_cases} matched cases.
\n------------------------------------------------------"
)
)
rv$data <- paste(
rv$data, glue::glue(
"\nIteration {i} produced {nrow(matched_data)} rows and {match_results$n_cases} matched cases.
\n------------------------------------------------------"
), sep = "\n"
)

# compare the results to the best results
if (is.null(best_matched_data())) {
Expand All @@ -99,26 +116,12 @@ server <- function(id, newFile, inputs) {
end_time <- proc.time()
comp_time <- end_time - start_time
print(glue::glue("\n\nTotal matching time: {round(comp_time[3], 2)} seconds"))
rv$data <- paste(
rv$data, glue::glue(
"\n\nTotal matching time: {round(comp_time[3], 2)} seconds"
), sep = "\n"
)

# return(best_matched_data)

# for (i in 1:1) {
# # Provide feedback to the user
# new_line <- glue::glue("Starting iteration {i}...")
# message(glue::glue("Starting iteration {i}..."))
#
# # run the matching algorithm
# results(
# matching_algo$mitter_match(
# newFile,
# inputs()$idVariable, inputs()$caseControl,
# inputs()$numericVariable, inputs()$numRange,
# inputs()$categoricalVariable, inputs()$ratio,
# inputs()$thirdVariable
# )
# )
#
# message(glue::glue("Ending iteration {i}"))
# # Provide feedback to the user
# result_line <- glue::glue(
# "\nIteration {i} produced {i} rows and XYZ matched cases.
Expand All @@ -132,9 +135,9 @@ server <- function(id, newFile, inputs) {

}, once = TRUE)

# output$iteration_results <- renderText({
# rv$data
# })
output$iteration_results <- renderText({
rv$data
})

# return(results)
return(best_matched_data)
Expand Down

0 comments on commit 4f94c46

Please sign in to comment.