Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Excel upload - Need to handle error when 'Run Tests' is pressed and there is a fatal TADA error raised #180

Open
5 tasks
JamesBisese opened this issue Nov 26, 2024 · 2 comments
Assignees

Comments

@JamesBisese
Copy link
Collaborator

JamesBisese commented Nov 26, 2024

Describe the bug

When loading data from an Excel file using the 'Run Test' button on the 'Flag' tab panel causes a fatal error that locks the screen for the user. In the console during debugging the message is

Error: (converted from warning) Error in dplyr::mutate:In argument: `MeasureQualifierCode.Split = strsplit(MeasureQualifierCode, ";")`.
Caused by error in `strsplit()`:
! non-character argument

To Reproduce

Steps to reproduce the behavior:

1. In the 'Load' tab panel, use the "Option C: Upload dataset" option to load the user file tada_output_utah_10rows.xlsx

2. Click on 'Flag' tab. In the Flag tab panel, click on the 'Run Tests' button

3. See UI error in the browser

image

If running in developer mode, the following is printed to the console

Error: (converted from warning) Error in dplyr::mutate:In argument: `MeasureQualifierCode.Split = strsplit(MeasureQualifierCode, ";")`.
Caused by error in `strsplit()`:
! non-character argument

If applicable, include code to reproduce the behavior:

By using a browser() statement, I can see that the MeasureQualifierCode are all the letters 'NA' which in the excel file are blank.

Browse[1]> tadat$raw$MeasureQualifierCode
 [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Reminders for TADA contributors addressing this issue

Bug fixes should include the following work:

  • Create or edit the code.

  • Document all code using line/inline and/or multi-line/block comments
    to describe what is does.

  • Create or edit tests in tests/testthat folder to help prevent and/or
    troubleshoot potential future issues.

  • If your code edits impact other functionality in the shiny
    app, ensure those are updated as well.

  • Run styler::style_pkg(), devtools::document(), and devtools::check()
    and address any new notes or issues before creating a pull request.

@JamesBisese
Copy link
Collaborator Author

JamesBisese commented Nov 27, 2024

When run on the excel file I get this result

Browse[1]> .data$MeasureQualifierCode
 [1] NA NA NA NA NA NA NA NA NA NA
Browse[1]> .data$MeasureQualifierCode.Split
Error: (converted from warning) Unknown or uninitialised column: `MeasureQualifierCode.Split`.
Browse[1]> flag.datazoom <- .data %>% dplyr::mutate(MeasureQualifierCode.Split = strsplit(MeasureQualifierCode, ";"))
Error in dplyr::mutate(., MeasureQualifierCode.Split = strsplit(MeasureQualifierCode,  : 
  ℹ In argument: `MeasureQualifierCode.Split = strsplit(MeasureQualifierCode, ";")`.
Caused by error in `strsplit()`:
! non-character argument
Browse[1]> 

When you download data using TADAShiny WQX query it is running TADA_AutoClean(TADAprofile)
It is the TADA_AutoClean() that is fixing something in the data.

These same operation is NOT performed on the imported excel file.

[1] "Data successfully downloaded. Running TADA_AutoClean function."
Called from: TADA_AutoClean(TADAprofile)
Browse[1]> c
[1] "TADA_Autoclean: creating TADA-specific columns."
[1] "TADA_Autoclean: harmonizing dissolved oxygen characterisic name to DISSOLVED OXYGEN SATURATION if unit is % or % SATURATN."
[1] "TADA_Autoclean: handling special characters and coverting TADA.ResultMeasureValue and TADA.DetectionQuantitationLimitMeasure.MeasureValue value fields to numeric."
[1] "TADA_Autoclean: converting TADA.LatitudeMeasure and TADA.LongitudeMeasure fields to numeric."
[1] "TADA_Autoclean: harmonizing synonymous unit names (m and meters) to m."
[1] "TADA_Autoclean: updating deprecated (i.e. retired) characteristic names."
[1] "No deprecated characteristic names found in dataset."
[1] "TADA_Autoclean: harmonizing result and depth units."
[1] "TADA_Autoclean: creating TADA.ComparableDataIdentifier field for use when generating visualizations and analyses."
[1] "NOTE: This version of the TADA package is designed to work with numeric data with media name: 'WATER'. TADA_AutoClean does not currently remove (filter) data with non-water media types. If desired, the user must make this specification on their own outside of package functions. Example: dplyr::filter(.data, TADA.ActivityMediaName == 'WATER')"
Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.

@JamesBisese
Copy link
Collaborator Author

JamesBisese commented Nov 27, 2024

Here is some test of the excel, running in TADA_FlagMeasureQualifierCode()

Browse[2]> .data$MeasureQualifierCode
 [1] NA NA NA NA NA NA NA NA NA NA
Browse[2]> is.character(.data$MeasureQualifierCode)
[1] FALSE
Browse[2]> typeof(.data$MeasureQualifierCode)
[1] "logical"
Browse[2]> 

And here is the same place with data pulled from the WQP

Called from: TADA_FlagMeasureQualifierCode(.data)
Browse[1]> .data$MeasureQualifierCode
 [1] NA   NA   NA   NA   NA   NA   NA   NA   NA   "KK" NA  
Browse[1]> is.character(.data$MeasureQualifierCode)
[1] TRUE
Browse[1]> typeof(.data$MeasureQualifierCode)
[1] "character"
Browse[1]> 

@JamesBisese JamesBisese self-assigned this Dec 5, 2024
@JamesBisese JamesBisese changed the title Need to handle error when 'Run Tests' is pressed and there is a fatal TADA error raised Using Excel upload - Need to handle error when 'Run Tests' is pressed and there is a fatal TADA error raised Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants