Uploading multiple files in Shiny, process the files, rbind the results and return a download

Uploading multiple files in Shiny, process the files, rbind the results and return a download

Content Index :

Uploading multiple files in Shiny, process the files, rbind the results and return a download
Tag : r , By : Gilmar Souza Jr.
Date : November 23 2020, 03:01 PM

Does that help The error is because the numfiles that you are calculating as numfiles = length(inFile) gives you the number of column in your inFile dataframe. You'll instead have to use numfiles = nrow(inFile) as the number of rows in the dataframe gives you the number of files that you have uploaded.
[EDIT]: The code that is working for me is:
 server <-  function(input, output) {
    getData <- reactive({
      inFile <- input$file1
      if (is.null(inFile)){
      }else {
        # browser()
        numfiles = nrow(inFile) 
        kata_csv1 = list()

        for (i in 1:numfiles)

          JSON_csv = read.csv(input$file1[[i, 'datapath']], header = TRUE)
          lastrow = nrow(JSON_csv)
          shift = function(x, n){
            c(x[-(seq(n))], rep(NA, n))
          JSON_csv$companyID1 = shift(JSON_csv$companyID1, 1)
          kata_csv1[[i]] = JSON_csv[-lastrow, ]

        # browser()
        do.call(rbind, kata_csv1)
    output$contents <- renderTable( 
    output$downloadData <- downloadHandler(
      filename = function() { 
        paste("data-", Sys.Date(), ".csv", sep="")
      content = function(file) { 
        write.csv(getData(), file, row.names=FALSE)   

 shinyApp(ui = ui, server = server)

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Download multiple csv files in a zipped folder in Shiny

Tag : r , By : paolodm
Date : March 29 2020, 07:55 AM
this will help The top solution still wasn't working for me. I was working in RStudio Server on a Linux server. The problem was that RStudio couldn't automatically locate the path to the zip executable. I had to manually specify it. In the command line, which zip revealed to me /usr/bin/zip.
So, I just had to set the R_ZIPCMD environment variable at the top of my code.

R shiny: download multiple .csv files

Tag : r , By : Hans-Inge
Date : March 29 2020, 07:55 AM
hop of those help? You forgot to put quotes"" in the qmethod argument. Your download handler for classify should be this:
output$download_classify <- downloadHandler(
      filename = function() {
        paste0("rating", ".csv")
      content = function(file) {
          sep = ";",
          col.names = NA,
          qmethod = "double"

Uploading multiple files in Shiny, process the files using lapply, rbind the results and return a download

Tag : r , By : micaleel
Date : March 29 2020, 07:55 AM
like below fixes the issue the problem is when you are passing inFile to lapply you are actually passing only the first column containing the filename. Instead you'll need to passinFile$datapath. The lapply should be like this:
   files3 = lapply(inFile$datapath, function(y){

     JSON_csv = read.csv(y, header = TRUE)
     lastrow = nrow(JSON_csv)
     shift = function(x, n){
       c(x[-(seq(n))], rep(NA, n))
     JSON_csv$companyID1 = shift(JSON_csv$companyID1, 1)
     JSON_csv = JSON_csv[-lastrow, ]

Uploading zip with multiple files into a shiny application

Tag : r , By : user107506
Date : March 29 2020, 07:55 AM
wish helps you It should be files <- unzip(input$upload$name, list = TRUE) instead of unzip(input$upload, list = TRUE)

Download multiple csv files with one button (downloadhandler) with R Shiny

Tag : r , By : dnyaneshwar
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Create a filled area line plot with plotly
  • When do I need parentheses around an if statement to control the sequence of a formula in R?
  • my graph in ggplot2 contains an "e" character in y-axis
  • Making variables immutable in R
  • R: Difference between the subsequent ranks of a item group by date
  • Match data within multiple time-frames with dplyr
  • Conditional manipulation and extension of rows in data.table also considering previous extensions without for-loop
  • Conditional formula referring to preview row in DF not working
  • Set hoverinfo text in plotly scatterplot
  • Histogram of Sums from Categorical/Binary Data
  • Efficiently find set differences and generate random sample
  • Find closest points from data set B to point in data set A, using lat long in R
  • dplyr join on column A OR column B
  • Replace all string if row starts with (within a column)
  • Is there a possibility to combine position_stack and nudge_x in a stacked bar chart in ggplot2?
  • How can I extract bounding boxes in a row-wise manner using R?
  • How do I easily sum up values in different columns?
  • Reading numeric Date value from CSV file to data.frame in "R"
  • R programming: creating a stacked bar graph, with variable colors for each stacked bar
  • How to identify all columns that contain binary representation
  • Filter different groups by different factor levels
  • Saving .xlsx file to disc, form http post request
  • Add an "all" option under the filter that selects the number of rows displayed in a datatable
  • How to select second column of every xts in list
  • Generate a frequency dataframe out of an input dataframe
  • Why manual autocorrelation does not match acf() results?
  • Merge 3 dataframes which are different to each other
  • remove adjacent duplicates from string
  • How to change the position of stacked stacked bar chart in ggplot in R?
  • How to divide each of a range a variables by a second range of variables in R
  • Why do I need to assemble vector before scaling in Spark?
  • How to select individuals which appear in multiple groups?
  • How can I fill columns based on values in another column?
  • 32 bit R and 64 bit R: output differs
  • Remove a single backslash in paste0 output
  • ggplot2 different label for the first break
  • TSP in R, with given distances
  • How to find the given value from the range of values?
  • Solution on R group by issue _ multiple combination
  • Transform multiple columns with a function that uses different arguments per column
  • How can I parse a string with the format "1/16/2019 1:24:51" into a POSIXct or other date variable?
  • How to plot a box plot in R for outlier detection for a huge number of rows?
  • How to change column name according to another dataframe in R?
  • `sjPlot::tab_df()`--how to set the number of decimal places?
  • time average for specific time range in r
  • joining dataframes by closest time and another key in r
  • How to create nested for loop for a certain range
  • New category based on sequence of date ranges
  • how to extract formula from coxph model summary in R?
  • add row based on variable condition in R
  • Generating the sequence 111122222333334
  • Unable to use has_goog_key() in R
  • how to multiply each row with a scaler in corresponding column?
  • R is not recognizing levels of a factor as the same. Is there a way to do this?
  • Calculating mean of replicate experiment result values in a column based on multiple columns using R
  • Best method to extract the first instance of a string between specified keywords using data.table
  • ignore optional combination of alphanumeric characters in str_extract
  • Why tracemem shows two copies when modification occurs inside function body?
  • Can't use mppm on multitype point patterns
  • How to move selected matrix rows to top of matrix based on a selection vector of row names
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com