How to save user responses in your google spreadsheet using R Shiny?

In this blog, you will learn how to easily save user responses in your google spreadsheet in R Shiny. We’ll use mainly the popular shiny package, which contains tags$iframe function to create an inline frame to embed an HTML document in R Shiny application. For more information like common attributes description of iframe check this. This blog also covered how to make google form in your google drive. If anyone has doesn’t make a google form then first create google form and after that connect it to shiny’s application. I hope this is useful to anyone wanting to save user responses in google spreadsheets.

Step 1: Create a form from Google Drive.

When you create a Google Form, it’s saved in Google Drive. To create a form directly from Google Drive:

  1. On a computer, go to the link.

  2. In the top left, click New.

  3. Click More > Google Forms. And make the google form according to your requirement.

4. In Google Forms there are two options in the top middle like Questions and Responses. Click Responses. So you can see below output in your Google Forms.

5. Now, click the green spreadsheet icon in the top right. After that, If you don’t have the existing spreadsheet then select the first option ‘create a new spreadsheet’ and click Create. So when users submit the responses then it will automatically store in the spreadsheet.

6. After completing above steps click the send button in the Google Forms. It shows various options to send form so from that click the link option then you can see the URL of your form. Copy that URL for further use. You can also make the URL short by selecting Shorten URL option.

Step 2: Save user responses using R Shiny.

First, you need to install the shiny package and load the library then you can wrap google form using Shiny's tags$iframe function. After that you can able to display the google form in your application and save the user responses in your spreadsheet.

library(shiny)ui <- shinyUI(navbarPage("App Title",
                                  tags$iframe(src = '',
                                              width = '100%',
                                              height = 500,
                                              frameborder = 0,
                                              marginheight = 0)
))server <- function(input, output, session) {
}shinyApp(ui, server)

Note that when you run the app locally, you must use “Open in Browser” to see the embedded Google Form!

Thank you

117 views0 comments

Recent Posts

See All

API/Web Service Overview:

So lets start off by learning what exactly is a Web Service? Its a method of communication between two applications or electronic devices over the worldwide web. Here is an example: Consider a flight