Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Link to the candy survey results #193

Closed
jennybc opened this issue Oct 27, 2015 · 2 comments
Closed

Link to the candy survey results #193

jennybc opened this issue Oct 27, 2015 · 2 comments

Comments

@jennybc
Copy link
Member

jennybc commented Oct 27, 2015

Visit it in the browser here:

https://docs.google.com/spreadsheets/d/1REZvjqv0lj3dEYb0CsGyDXkXrjhJ4izlAEImgaufjCc/pubhtml

@jennybc
Copy link
Member Author

jennybc commented Oct 27, 2015

Here's a snippet of code to get you started with this data in R:

# install.packages("googlesheets")
# or
# devtools::install_github("jennybc/googlesheets")
library(googlesheets)
library(dplyr)
library(readr)

gs_auth(new_user = TRUE)
#> Waiting for authentication in browser...
#> Press Esc/Ctrl + C to abort
#> Authentication complete.
candy_key <- "1REZvjqv0lj3dEYb0CsGyDXkXrjhJ4izlAEImgaufjCc"
candy_ss <- candy_key %>% 
  gs_key(lookup = FALSE)  
#> Authorization will not be used.
#> Worksheets feed constructed with public visibility
candy_ss
#>                   Spreadsheet title: CANDY HIERARCHY 2015 SURVEY (Responses)
#>                  Spreadsheet author: davehwng
#>   Date of googlesheets registration: 2015-10-27 17:38:55 GMT
#>     Date of last spreadsheet update: 2015-10-27 17:36:01 GMT
#>                          visibility: public
#>                         permissions: rw
#>                             version: new
#> 
#> Contains 1 worksheets:
#> (Title): (Nominal worksheet extent as rows x columns)
#> Form Responses 1: 2814 x 148
#> 
#> Key: 1REZvjqv0lj3dEYb0CsGyDXkXrjhJ4izlAEImgaufjCc
#> Browser URL: https://docs.google.com/spreadsheets/d/1REZvjqv0lj3dEYb0CsGyDXkXrjhJ4izlAEImgaufjCc/

## for the moment, read to local csv then import
candy_ss %>%
  gs_download(to = "candy.csv")
#> Sheet successfully downloaded: /private/var/folders/5c/rwqfdv6s30n3kvfnvxdk19cw0000gn/T/RtmpFhi48F/candy.csv
candy <- read_csv("candy.csv")
candy
#> Source: local data frame [1,813 x 124]
#> 
#>             Timestamp How old are you?
#>                 (chr)            (chr)
#> 1  10/23/2015 8:46:20               35
#> 2  10/23/2015 8:46:52               41
#> 3  10/23/2015 8:47:34               33
#> 4  10/23/2015 8:47:59               31
#> 5  10/23/2015 8:48:12               30
#> 6  10/23/2015 8:49:07               38
#> 7  10/23/2015 8:50:09               48
#> 8  10/23/2015 8:52:14               39
#> 9  10/23/2015 8:52:22            9E+22
#> 10 10/23/2015 8:53:31               54
#> ..                ...              ...
#> Variables not shown: Are you going actually going trick or treating
#>   yourself? (chr), [Butterfinger] (chr), [100 Grand Bar] (chr), [Anonymous
#>   brown globs that come in black and orange wrappers] (chr), [Any
#>   full-sized candy bar] (chr), [Black Jacks] (chr), [Bonkers] (chr),
#>   [Bottle Caps] (chr), [Box’o’ Raisins] (chr), [Brach products (not
#>   including candy corn)] (chr), [Bubble Gum] (chr), [Cadbury Creme Eggs]
#>   (chr), ...
#>   AND IT GOES ON AND ON

@jennybc
Copy link
Member Author

jennybc commented Oct 28, 2015

Another alternative is to copy the survey data to your own Drive, then read from your copy.

library(googlesheets)
library(dplyr)

candy_key <- "1REZvjqv0lj3dEYb0CsGyDXkXrjhJ4izlAEImgaufjCc"
candy_ss <- candy_key %>% 
  gs_key(lookup = FALSE)  
#> Authorization will not be used.
#> Worksheets feed constructed with public visibility
candy_ss
#>                   Spreadsheet title: CANDY HIERARCHY 2015 SURVEY (Responses)
#>                  Spreadsheet author: davehwng
#>   Date of googlesheets registration: 2015-10-28 05:37:42 GMT
#>     Date of last spreadsheet update: 2015-10-28 05:30:07 GMT
#>                          visibility: public
#>                         permissions: rw
#>                             version: new
#> 
#> Contains 1 worksheets:
#> (Title): (Nominal worksheet extent as rows x columns)
#> Form Responses 1: 2878 x 148
#> 
#> Key: 1REZvjqv0lj3dEYb0CsGyDXkXrjhJ4izlAEImgaufjCc
#> Browser URL: https://docs.google.com/spreadsheets/d/1REZvjqv0lj3dEYb0CsGyDXkXrjhJ4izlAEImgaufjCc/

## copy the candy survey data to your drive
my_candy_ss <- candy_ss %>%
  gs_copy()
#> Successful copy! New sheet is titled "Copy of CANDY HIERARCHY 2015 SURVEY (Responses)".
## read the data from there
my_candy <- my_candy_ss %>% 
  gs_read()
#> Accessing worksheet titled "Form Responses 1"
my_candy
#> Source: local data frame [1,877 x 124]
#> 
#>             Timestamp How.old.are.you.
#>                 (chr)            (chr)
#> 1  10/23/2015 8:46:20               35
#> 2  10/23/2015 8:46:52               41
#> 3  10/23/2015 8:47:34               33
#> 4  10/23/2015 8:47:59               31
#> 5  10/23/2015 8:48:12               30
#> 6  10/23/2015 8:49:07               38
#> 7  10/23/2015 8:50:09               48
#> 8  10/23/2015 8:52:14               39
#> 9  10/23/2015 8:52:22            9E+22
#> 10 10/23/2015 8:53:31               54
#> ..                ...              ...
#> Variables not shown:
#>   Are.you.going.actually.going.trick.or.treating.yourself. (chr),
#>   X.Butterfinger. (chr), X.100.Grand.Bar. (chr),
#>   AND IT GOES ON AND ON

@jennybc jennybc closed this as completed Aug 30, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant