Download button on Rshiny platform for collecting numerous files from different sources

I am on a quest for knowledge regarding the inclusion of a download button in my application that consolidates various files into a zip archive.

Within my application, there are a timeline and a datatable, with files linked to entries on the datatable. These files are stored in a directory within the app, with filenames listed in a column of the datatable.

The plan is to generate a zip archive containing a selection of standard files, a csv version of the datatable, a png image of the timeline, and any files associated with the chosen entries from the datatable upon clicking the download button.

I have yet to address the files associated with the datatable entries, but that is my ultimate goal.

Current Code

library(shiny)
library(timevis)
library(lubridate)
library(dplyr)

starthour <- 8
today <- as.character(Sys.Date())
todayzero <- paste(today,"00:00:00")
todayAM <- paste(today,"07:00:00")
todayPM <- paste(today, "18:00:00")

items <- data.frame(
  category = c("Room","IceBreaker","Activity","Break"),
  group=c(1,2,3,4),
  className   = c ("red_point", "blue_point", "green_point","purple_point"),
  content = c("Big Room","Introductions","Red Rover","Lunch"),
  length = c(480,60,120,90)
)
...

EDIT

At present, the method I am employing to download selected rows from a datatable in my live application is as follows:

output$downloadData2 <- downloadHandler(
      filename = function() {paste('Selected Retreat Options', Sys.Date(), '.csv', sep = '')},
      content = function(file){ write.csv(thedata()[input[["tbl1_rows_selected"]], ],file)})

Answer №1

Learn how to utilize the power of JavaScript libraries with the following approach:

  • dom-to-image can help export the timeline as a PNG image;

  • table2CSV enables you to convert the table to a CSV string;

  • JSZip for zipping purposes.


Implement the solution in a Shiny environment using the following packages: shiny, timevis, lubridate, and dplyr. This approach involves data manipulation and JavaScript integration for interactive timeline visualization.

EDIT

Another solution that eliminates the need to display the table on the page. This method incorporates the PapaParse JavaScript library for enhanced functionality.

Integrate the PapaParse library with the existing JavaScript libraries to improve the download functionality. This solution optimizes the timeline downloading process without requiring the table to be visible on the page.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error during compilation in npm (symbol '_' is not recognized)

After updating all the dependencies in my JavaScript program without making any changes to my components, I encountered an error when running: npm run build The error specifically mentions a problem with one of my components: Failed to compile. ./src/c ...

Utilize dplyr and stringr to extract words from a given text

I am currently exploring methods to extract specific words from a text column within a dataset. My current approach involves using the following code: library(dplyr) library(stringr) Text = c("A little bird told me about the dog", "A pig in a poke", "As ...

Getting access to the parent's ref from child components in Vue/Nuxt can be achieved by using

Incorporating a global confirm modal component into my default layout file has been a challenge. Attempting to access this component from my pages/index.vue has proven to be unsuccessful, as calling this.$refs returns an empty object. While placing the mod ...

Attempting to insert the symbol "$gt" into a query for a search. {[CastError: Unable to convert value "[object Object]" to date at path "createdAt"]}

In the following code snippet: Reviews.find({createdAt : {"$lt" : app.locals.lastDate}}), I am trying to dynamically change the $lt to $gt. app.post("/scroll", function(req, res){ console.log("req.body...", req.body); var sortCreate = req.body.old ...

Exploring nested static properties within TypeScript class structures

Check out this piece of code: class Hey { static a: string static b: string static c: string static setABC(a: string, b: string, c: string) { this.a = a this.b = b this.c = c return this } } class A { static prop1: Hey static ...

eliminating strands from a collection

Dealing with unprocessed text data extracted from a scanned catalog. I am only interested in preserving two types of strings: - those starting with a number (artists' works) - those containing 2 adjacent uppercase letters **with accents** (artis ...

Excluding identification codes from PCA visualization using ggbiplot in R programming

Is there a way to eliminate the sample IDs from a ggbiplot and replace them with dots representing each sample? The current script I'm using is cluttered with IDs due to the amount of data in my PCA, so I would prefer to use dots or circles instead. ...

Removing missing values in individual graphs [R]

Struggling with eliminating NAs from my R plot... Despite using [na.rm=TRUE], the NAs are persisting in my plot. Removing all NAs from the entire dataset is not feasible, as it would result in loss of crucial information. My goal is to only exclude them f ...

Exploring VueJS: Sorting objects within an array

Currently, I am tackling a challenge in vue-js. In my codebase, there exists a data object known as items. I am iterating through these items and aiming to present a dropdown menu containing the list of products. My goal now is to showcase only those pro ...

Collapse an array containing objects with nested objects inside

Similar questions can be found here and here, but I am struggling to modify the code provided in the answers to fit my specific needs due to its conciseness. The structure of my array of objects is as follows: [ { id: 1, someProp: &quo ...

Tips on updating service variable values dynamically

I need to update a date value that is shared across all controllers in my website dynamically. The goal is to have a common date displayed throughout the site by updating it from any controller and having the new value reflected on all controllers. Can yo ...

Instructions on how to use a keyboard key to activate a dropdown menu item in Bootstrap

Bootstrap 5 navbar features dropdown menus that have underlined hotkeys such as a,n,s, and e. https://i.sstatic.net/bZOaC1kU.png <div class="btn-group"> <button type="button" class="btn btn-danger dropdown-toggle" ...

Can you demonstrate how to incorporate a new line within a for loop?

I have an array of letters and I need to display them on the screen using a for loop. My goal is to make every sixth letter appear on a new line. Here is the code snippet: https://i.stack.imgur.com/lHFqq.jpg <script> export default { data() { ...

"Encountering an OutOfMemory error on the Java heap space when using the SparkR collect

I am currently using SparkR to conduct a Proof of Concept (PoC) aimed at gathering an RDD generated from text files containing approximately 4 million lines. The setup for my Spark cluster involves it running on Google Cloud, with bdutil deployed and comp ...

The error message "Uncaught ReferenceError: require is not defined" is commonly encountered when using Webpack

Despite countless similar questions, none have provided a solution to my issue because the underlying problem seems to elude me. I am attempting to bundle files for the browser using webpack 4.26.1, but no matter what I try, I consistently encounter the er ...

Vue 3's click event handler does not recognize $options.x as a valid function

I'm encountering a perplexing issue. I am currently in the process of creating a Wordpress plugin using Vue, but unfortunately, I am unable to establish functionality for the @click event. <script> export default { name: "App", me ...

Unable to fetch local file using ajax from a local HTML page

According to Same Origin Policy, the SOP should not be applied to the file:// protocol. However, I'm having trouble with my code. I am running a testing page from my local system, and both when I try to access abc.txt in the same directory as the HTML ...

Examples of various spatial categories in the gun database, such as public space, user space, and frozen space

It appears that the Gun functionality is quite impressive - both practical and user-friendly! However, I am having trouble grasping the distinction between a public space put, a user space put, and a frozen space put. I've tried to illustrate this wit ...

Combining a pair of canvases

Currently, I am utilizing a JavaScript library to create a QR Code. This library generates the QR code by displaying it on a canvas. Nevertheless, my goal is to integrate a background behind this QR Code. I attempted to achieve this by first drawing the b ...

The utcParse() function in D3.js might return a null value

I am struggling to parse a date format that appears as follows: 2017-02-18T09:00:00+06:00. Currently, I am attempting to use the following format for parsing: d3.utcParse("%Y-%m-%dT%H:%M:%S+%Z");, however, it is returning null. Do you have any suggesti ...