Hi,
So I have a simple shiny app to download a tsv file with a data set that is itself downloaded from a database. I have only one function, that downloads the dataset and changes and normalizes it along the way, until I have a final one which is the one that is supposed to be downloaded through the app.
The function is this one:
library(seqRFLP)
library(bold)
library(data.table)
library(rentrez)
library(worms)
library(stringr)
library(readr)
library(fingerprint)
library(dplyr)
library(ggplot2)
library(shiny)
library(rsconnect)
grades<-function(groups){
taxon<-bold_seqspec(taxon=input$taxa, format = "tsv", marker="COI-5P")
taxon2<-taxon[(!(is.na(taxon$lat)) | taxon$country!="") & (taxon$species_name!=""),]
taxon2$number<-str_count(taxon2$nucleotides, pattern="[A-Z]")
taxon3<-taxon2[(taxon2$number>499),]
taxon3$species_name<-gsub("sp.", "", taxon3$species_name)
taxon3$species_name<-gsub("sp. nov", "", taxon3$species_name)
taxon3$species_name<-gsub("cf.", "", taxon3$species_name)
taxon3$species_name<-gsub("complex.", "", taxon3$species_name)
taxon3$species_name<-gsub("cmplx.", "", taxon3$species_name)
taxon3$species_name<-gsub("[1-9]+", "", taxon3$species_name)
taxon3=subset(taxon3, lengths(gregexpr("\\w+", taxon3$species_name)) > 1)
taxon4<-wormsbynames(as.character(taxon3$species_name), marine_only=FALSE, ids=TRUE)
taxon5<-subset(taxon4, taxon4$isMarine=="1" | taxon4$isBrackish=="1")
taxon6<-subset(taxon3,as.character(taxon3$species_name)%in% as.character(taxon5$name))
input$taxa=taxon6
}
Then here is the small app:
ui <- fluidPage(
titlePanel("Downloading Dataframe with specimen + sequence data"),
textInput(inputId="taxa",
label="Enter the name of the taxon:",placeholder="Example: Cetacea"),
downloadButton("downloadData","Download")
)
server <- function(input, output){
taxaInput <- reactive({switch(grades(input$taxa))})
output$downloadData <- downloadHandler(
filename = function() {
paste(input$taxa, ".tsv")
},
content = function(file) {
write.csv(taxaInput(), file, row.names = FALSE)
})
}
shinyApp(ui=ui,server=server)
So when I click "Download" in the app and choose where I want to save the file I receive the following error:</>
Thanks for any response in advance and sorry for the long question