Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,22 @@ app_server <- function(input, output, session) {
# reactive variables

rawdata <- reactive({
req(input$upload)
req(input$upload) # Ensure the file is uploaded
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for checking out searchbuildR! I am wondering why this error occurs for you. Should this not be handled by line 43 req() without any further checks necessary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would make sense to me! I am not sure but it seems to be because of the switch() which is looking for either txt or ris file. Shiny can be a bit weird about how it runs code (not always in what we think is "order")


ext <- tools::file_ext(input$upload$name)
switch(ext,
txt = create_testset(input$upload$datapath),
ris = create_testset(input$upload$datapath),
validate("Invalid file: Please upload a risfile exported from Endnote or PubMed")

# Ensure ext is a single value and handle invalid file extensions
if (length(ext) != 1 || ext == "") {
validate("Please upload a file")
}

result <- switch(ext,
txt = create_testset(input$upload$datapath),
ris = create_testset(input$upload$datapath),
validate("Invalid file: Please upload a ris file exported from Endnote or PubMed")
)

result
})
allRefsTable <- reactive({
columns <- c("accession", "author", "year", "title")
Expand Down