From e1f6c2362cfc2c9209365e3f7ebbc9dcabf67d5c Mon Sep 17 00:00:00 2001 From: jennybc Date: Tue, 7 Jul 2015 10:37:03 +0200 Subject: [PATCH] update README; recompile vignette [skip ci] --- README.Rmd | 8 +- README.md | 10 +- vignettes/basic-usage.R | 202 ++----------------------------------- vignettes/basic-usage.html | 79 ++++++++------- vignettes/basic-usage.md | 78 +++++++------- 5 files changed, 98 insertions(+), 279 deletions(-) diff --git a/README.Rmd b/README.Rmd index 3ac027d..5dfb4ee 100644 --- a/README.Rmd +++ b/README.Rmd @@ -63,14 +63,16 @@ What other ideas do you have? ### Install googlesheets +The released version is available on CRAN + ```{r eval = FALSE} -devtools::install_github("jennybc/googlesheets") +install.packages("googlesheets") ``` -*It's not on CRAN yet but that is hopefully imminent. So then this will work.* +Or you can get the development version from GitHub: ```{r eval = FALSE} -install.packages("googlesheets") +devtools::install_github("jennybc/googlesheets") ``` ### Take a look at the vignette diff --git a/README.md b/README.md index 8ca4797..e11da32 100644 --- a/README.md +++ b/README.md @@ -41,14 +41,16 @@ What other ideas do you have? ### Install googlesheets +The released version is available on CRAN + ``` r -devtools::install_github("jennybc/googlesheets") +install.packages("googlesheets") ``` -*It's not on CRAN yet but that is hopefully imminent. So then this will work.* +Or you can get the development version from GitHub: ``` r -install.packages("googlesheets") +devtools::install_github("jennybc/googlesheets") ``` ### Take a look at the vignette @@ -96,7 +98,7 @@ Here's a registered `googlesheet` object: gap #> Spreadsheet title: Gapminder #> Spreadsheet author: gspreadr -#> Date of googlesheets registration: 2015-07-02 10:46:41 GMT +#> Date of googlesheets registration: 2015-07-07 08:33:29 GMT #> Date of last spreadsheet update: 2015-03-23 20:34:08 GMT #> visibility: private #> permissions: rw diff --git a/vignettes/basic-usage.R b/vignettes/basic-usage.R index de6f976..2e1805f 100644 --- a/vignettes/basic-usage.R +++ b/vignettes/basic-usage.R @@ -2,202 +2,12 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>", - fig.path = "README-" + fig.path = "README-", + purl = FALSE ) - -## ----auth, include = FALSE----------------------------------------------- -## I grab the token from the testing directory because that's where it is to be -## found on Travis -token_path <- file.path("..", "tests", "testthat", "googlesheets_token.rds") -suppressMessages(googlesheets::gs_auth(token = token_path, verbose = FALSE)) - -## ----pre-clean, include = FALSE------------------------------------------ -## if a previous compilation of this document leaves anything behind, i.e. if it -## aborts, clean up Google Drive first -googlesheets::gs_vecdel(c("foo", "iris"), verbose = FALSE) -file.remove(c("gapminder.xlsx", "gapminder-africa.csv", "iris")) - -## ----load package-------------------------------------------------------- -library(googlesheets) -suppressMessages(library(dplyr)) - -## ----list-sheets--------------------------------------------------------- -(my_sheets <- gs_ls()) -# (expect a prompt to authenticate with Google interactively HERE) -my_sheets %>% glimpse() - -## ----copy-gapminder, eval = FALSE---------------------------------------- -# gs_gap() %>% -# gs_copy(to = "Gapminder") - -## ----register-sheet------------------------------------------------------ -gap <- gs_title("Gapminder") -gap - -# Need to access a sheet you do not own? -# Access it by key if you know it! -(GAP_KEY <- gs_gap_key()) -third_party_gap <- GAP_KEY %>% - gs_key() - -# Need to access a sheet you do not own but you have a sharing link? -# Access it by URL! -(GAP_URL <- gs_gap_url()) -third_party_gap <- GAP_URL %>% - gs_url() -# note: registration via URL may not work for "old" sheets - -# Worried that a spreadsheet's registration is out-of-date? -# Re-register it! -gap <- gap %>% gs_gs() - -## ------------------------------------------------------------------------ -oceania <- gap %>% gs_read(ws = "Oceania") -oceania -str(oceania) -glimpse(oceania) - -## ------------------------------------------------------------------------ -gap %>% gs_read(ws = 2, range = "A1:D8") -gap %>% gs_read(ws = "Europe", range = cell_rows(1:4)) -gap %>% gs_read(ws = "Europe", range = cell_rows(100:103), col_names = FALSE) -gap %>% gs_read(ws = "Africa", range = cell_cols(1:4)) -gap %>% gs_read(ws = "Asia", range = cell_limits(c(1, 4), c(5, NA))) - -## ----csv-list-and-cell-feed---------------------------------------------- -# Get the data for worksheet "Oceania": the super-fast csv way -oceania_csv <- gap %>% gs_read_csv(ws = "Oceania") -str(oceania_csv) -oceania_csv - -# Get the data for worksheet "Oceania": the less-fast tabular way ("list feed") -oceania_list_feed <- gap %>% gs_read_listfeed(ws = "Oceania") -str(oceania_list_feed) -oceania_list_feed - -# Get the data for worksheet "Oceania": the slow cell-by-cell way ("cell feed") -oceania_cell_feed <- gap %>% gs_read_cellfeed(ws = "Oceania") -str(oceania_cell_feed) -oceania_cell_feed - -## ------------------------------------------------------------------------ -jfun <- function(readfun) - system.time(do.call(readfun, list(gs_gap(), ws = "Africa", verbose = FALSE))) -readfuns <- c("gs_read_csv", "gs_read_listfeed", "gs_read_cellfeed") -readfuns <- sapply(readfuns, get, USE.NAMES = TRUE) -sapply(readfuns, jfun) - -## ----post-processing----------------------------------------------------- -# Reshape: instead of one row per cell, make a nice rectangular data.frame -australia_cell_feed <- gap %>% - gs_read_cellfeed(ws = "Oceania", range = "A1:F13") -str(australia_cell_feed) -oceania_cell_feed -australia_reshaped <- australia_cell_feed %>% gs_reshape_cellfeed() -str(australia_reshaped) -australia_reshaped - -# Example: first 3 rows -gap_3rows <- gap %>% gs_read_cellfeed("Europe", range = cell_rows(1:3)) -gap_3rows %>% head() - -# convert to a data.frame (by default, column names found in first row) -gap_3rows %>% gs_reshape_cellfeed() - -# arbitrary cell range, column names no longer available in first row -gap %>% - gs_read_cellfeed("Oceania", range = "D12:F15") %>% - gs_reshape_cellfeed(col_names = FALSE) - -# arbitrary cell range, direct specification of column names -gap %>% - gs_read_cellfeed("Oceania", range = cell_limits(c(2, 1), c(5, 3))) %>% - gs_reshape_cellfeed(col_names = paste("thing", c("one", "two", "three"), - sep = "_")) - -## ------------------------------------------------------------------------ -# Example: first row only -gap_1row <- gap %>% gs_read_cellfeed("Europe", range = cell_rows(1)) -gap_1row - -# convert to a named character vector -gap_1row %>% gs_simplify_cellfeed() - -# Example: single column -gap_1col <- gap %>% gs_read_cellfeed("Europe", range = cell_cols(3)) -gap_1col - -# convert to a un-named character vector and drop the variable name -gap_1col %>% gs_simplify_cellfeed(notation = "none", col_names = TRUE) - -## ----new-sheet----------------------------------------------------------- -foo <- gs_new("foo") -foo - -## ----edit-cells---------------------------------------------------------- -## foo <- gs_new("foo") -## initialize the worksheets -foo <- foo %>% gs_ws_new("edit_cells") -foo <- foo %>% gs_ws_new("add_row") - -## add first six rows of iris data (and var names) into a blank sheet -foo <- foo %>% - gs_edit_cells(ws = "edit_cells", input = head(iris), trim = TRUE) - -## initialize sheet with column headers and one row of data -## the list feed is picky about this -foo <- foo %>% - gs_edit_cells(ws = "add_row", input = head(iris, 1), trim = TRUE) -## add the next 5 rows of data -for(i in 2:6) { - foo <- foo %>% gs_add_row(ws = "add_row", input = iris[i, ]) +if(identical(tolower(Sys.getenv("NOT_CRAN")), "true")) { + NOT_CRAN <- TRUE +} else { + NOT_CRAN <- FALSE } -## let's inspect out work -foo %>% gs_read(ws = "edit_cells") -foo %>% gs_read(ws = "add_row") - -## ----delete-sheet-------------------------------------------------------- -gs_delete(foo) - -## ----new-sheet-from-file------------------------------------------------- -iris %>% - head(5) %>% - write.csv("iris.csv", row.names = FALSE) -iris_ss <- gs_upload("iris.csv") -iris_ss -iris_ss %>% gs_read() -file.remove("iris.csv") - -## ----new-sheet-from-xlsx------------------------------------------------- -gap_xlsx <- gs_upload(system.file("mini-gap.xlsx", package = "googlesheets")) -gap_xlsx -gap_xlsx %>% gs_read(ws = "Asia") - -## ----delete-moar-sheets-------------------------------------------------- -gs_vecdel(c("iris", "mini-gap")) -## achieves same as: -## gs_delete(iris_ss) -## gs_delete(gap_xlsx) - -## ----export-sheet-as-csv------------------------------------------------- -gs_title("Gapminder") %>% - gs_download(ws = "Africa", to = "gapminder-africa.csv") -## is it there? yes! -read.csv("gapminder-africa.csv") %>% head() - -## ----export-sheet-as-xlsx------------------------------------------------ -gs_title("Gapminder") %>% - gs_download(to = "gapminder.xlsx") - -## ----clean-exported-files------------------------------------------------ -file.remove(c("gapminder.xlsx", "gapminder-africa.csv")) - -## ----gs_auth, eval = FALSE----------------------------------------------- -# # Give googlesheets permission to access your spreadsheets and google drive -# gs_auth() - -## ----gs_user------------------------------------------------------------- -user_session_info <- gs_user() -user_session_info - diff --git a/vignettes/basic-usage.html b/vignettes/basic-usage.html index f319350..c240a8b 100644 --- a/vignettes/basic-usage.html +++ b/vignettes/basic-usage.html @@ -10,7 +10,7 @@ - + googlesheets Basic Usage @@ -54,7 +54,7 @@
@@ -79,31 +79,31 @@

2015-07-01

See some spreadsheets you can access

The gs_ls() function returns the sheets you would see in your Google Sheets home screen: https://docs.google.com/spreadsheets/. This should include sheets that you own and may also show sheets owned by others but that you are permitted to access, if you visited the sheet in the browser. Expect a prompt to authenticate yourself in the browser at this point (more below re: authentication).

(my_sheets <- gs_ls())
-#> Source: local data frame [41 x 10]
+#> Source: local data frame [42 x 10]
 #> 
 #>                 sheet_title        author perm version             updated
-#> 1  Copy of Twitter Archive…   joannazhaoo    r     new 2015-07-01 07:24:25
-#> 2               gas_mileage      woo.kara    r     new 2015-07-01 02:21:07
-#> 3                  for_sean      gspreadr   rw     new 2015-06-23 18:33:10
-#> 4               TAGS v6.0ns     m.hawksey    r     new 2015-06-22 19:17:33
-#> 5   EasyTweetSheet - Shared     m.hawksey    r     new 2015-06-18 16:07:23
-#> 6  Supervisor Interests (R… silwood.mast…    r     new 2015-06-08 08:59:51
-#> 7          Projects_2013_14    david.orme    r     new 2015-06-08 08:59:44
-#> 8   Craigslist Lost & Found   joannazhaoo    r     new 2015-06-01 22:35:04
-#> 9              #rhizo15 #tw     m.hawksey    r     new 2015-06-01 15:41:47
-#> 10 Ari's Anchor Text Scrap…      anahmani    r     new 2015-05-29 07:18:48
+#> 1  Copy of Twitter Archive…   joannazhaoo    r     new 2015-07-07 08:31:25
+#> 2               gas_mileage      woo.kara    r     new 2015-07-07 00:19:42
+#> 3  test-gs-jenny-121c66d79…      gspreadr   rw     new 2015-07-06 17:08:26
+#> 4  Tweet Collector (TAGS v…      gspreadr   rw     new 2015-07-01 13:43:14
+#> 5           #TalkPay Tweets      iskaldur    r     new 2015-07-01 08:06:22
+#> 6                  for_sean      gspreadr   rw     new 2015-06-23 18:33:10
+#> 7               TAGS v6.0ns     m.hawksey    r     new 2015-06-22 19:17:33
+#> 8   EasyTweetSheet - Shared     m.hawksey    r     new 2015-06-18 16:07:23
+#> 9  Supervisor Interests (R… silwood.mast…    r     new 2015-06-08 08:59:51
+#> 10         Projects_2013_14    david.orme    r     new 2015-06-08 08:59:44
 #> ..                      ...           ...  ...     ...                 ...
 #> Variables not shown: sheet_key (chr), ws_feed (chr), alternate (chr), self
 #>   (chr), alt_key (chr)
 # (expect a prompt to authenticate with Google interactively HERE)
 my_sheets %>% glimpse()
-#> Observations: 41
+#> Observations: 42
 #> Variables:
-#> $ sheet_title (chr) "Copy of Twitter Archiver v2.1", "gas_mileage", "f...
-#> $ author      (chr) "joannazhaoo", "woo.kara", "gspreadr", "m.hawksey"...
-#> $ perm        (chr) "r", "r", "rw", "r", "r", "r", "r", "r", "r", "r",...
+#> $ sheet_title (chr) "Copy of Twitter Archiver v2.1", "gas_mileage", "t...
+#> $ author      (chr) "joannazhaoo", "woo.kara", "gspreadr", "gspreadr",...
+#> $ perm        (chr) "r", "r", "rw", "rw", "r", "rw", "r", "r", "r", "r...
 #> $ version     (chr) "new", "new", "new", "new", "new", "new", "new", "...
-#> $ updated     (time) 2015-07-01 07:24:25, 2015-07-01 02:21:07, 2015-06...
+#> $ updated     (time) 2015-07-07 08:31:25, 2015-07-07 00:19:42, 2015-07...
 #> $ sheet_key   (chr) "1DoMXh2m3FGPoZAle9vnzg763D9FESTU506iqWkUTwtE", "1...
 #> $ ws_feed     (chr) "https://spreadsheets.google.com/feeds/worksheets/...
 #> $ alternate   (chr) "https://docs.google.com/spreadsheets/d/1DoMXh2m3F...
@@ -127,7 +127,7 @@ 

Register a spreadsheet

gap #> Spreadsheet title: Gapminder #> Spreadsheet author: gspreadr -#> Date of googlesheets registration: 2015-07-01 07:26:48 GMT +#> Date of googlesheets registration: 2015-07-07 08:34:20 GMT #> Date of last spreadsheet update: 2015-03-23 20:34:08 GMT #> visibility: private #> permissions: rw @@ -369,9 +369,9 @@

Quick speed comparison

readfuns <- sapply(readfuns, get, USE.NAMES = TRUE) sapply(readfuns, jfun) #> gs_read_csv gs_read_listfeed gs_read_cellfeed -#> user.self 0.031 0.136 0.989 -#> sys.self 0.002 0.014 0.046 -#> elapsed 1.308 1.719 3.339 +#> user.self 0.034 0.134 1.011 +#> sys.self 0.002 0.013 0.040 +#> elapsed 0.706 1.654 4.466 #> user.child 0.000 0.000 0.000 #> sys.child 0.000 0.000 0.000
@@ -569,8 +569,8 @@

Create sheets

foo #> Spreadsheet title: foo #> Spreadsheet author: gspreadr -#> Date of googlesheets registration: 2015-07-01 07:27:15 GMT -#> Date of last spreadsheet update: 2015-07-01 07:27:13 GMT +#> Date of googlesheets registration: 2015-07-07 08:34:52 GMT +#> Date of last spreadsheet update: 2015-07-07 08:34:49 GMT #> visibility: private #> permissions: rw #> version: new @@ -579,8 +579,8 @@

Create sheets

#> (Title): (Nominal worksheet extent as rows x columns) #> Sheet1: 1000 x 26 #> -#> Key: 1E4R8x4fpHCozG3nc_AIN3xWPWGoR9SlKrTIRzLwH6HI -#> Browser URL: https://docs.google.com/spreadsheets/d/1E4R8x4fpHCozG3nc_AIN3xWPWGoR9SlKrTIRzLwH6HI/ +#> Key: 1Tg_XFZfvGTHWc-ZSgg5Ipjj4taZnjg_W5-nPsWAayVc +#> Browser URL: https://docs.google.com/spreadsheets/d/1Tg_XFZfvGTHWc-ZSgg5Ipjj4taZnjg_W5-nPsWAayVc/

By default, there will be an empty worksheet called “Sheet1”, but you can control it’s title, extent, and initial data with additional arguments to gs_new() (see gs_edit_cells() in the next section). You can also add, rename, and delete worksheets within an existing sheet via gs_ws_new(), gs_ws_rename(), and gs_ws_delete(). Copy an entire spreadsheet with gs_copy().

@@ -623,9 +623,10 @@

Edit cells

#> Sheet successfully identifed: "foo" #> Accessing worksheet titled "add_row" #> Worksheet "add_row" dimensions changed to 2 x 5. -## add the next 5 rows of data +## add the next 5 rows of data ... careful not to go too fast for(i in 2:6) { foo <- foo %>% gs_add_row(ws = "add_row", input = iris[i, ]) + Sys.sleep(0.3) } #> Row successfully appended. #> Row successfully appended. @@ -678,8 +679,8 @@

Upload delimited files or Excel workbooks

iris_ss #> Spreadsheet title: iris #> Spreadsheet author: gspreadr -#> Date of googlesheets registration: 2015-07-01 07:27:50 GMT -#> Date of last spreadsheet update: 2015-07-01 07:27:47 GMT +#> Date of googlesheets registration: 2015-07-07 08:35:34 GMT +#> Date of last spreadsheet update: 2015-07-07 08:35:32 GMT #> visibility: private #> permissions: rw #> version: new @@ -688,8 +689,8 @@

Upload delimited files or Excel workbooks

#> (Title): (Nominal worksheet extent as rows x columns) #> iris: 1000 x 26 #> -#> Key: 1Zw0L68up_wubuqAUiIOPB2N_OuhMfhbhZjrKd6XSQ70 -#> Browser URL: https://docs.google.com/spreadsheets/d/1Zw0L68up_wubuqAUiIOPB2N_OuhMfhbhZjrKd6XSQ70/ +#> Key: 13SkrPLW6QdKW4XduDXycp1TVtuW-UwSu2go2p6UbyoY +#> Browser URL: https://docs.google.com/spreadsheets/d/13SkrPLW6QdKW4XduDXycp1TVtuW-UwSu2go2p6UbyoY/ iris_ss %>% gs_read() #> Accessing worksheet titled "iris" #> Source: local data frame [5 x 5] @@ -708,8 +709,8 @@

Upload delimited files or Excel workbooks

gap_xlsx #> Spreadsheet title: mini-gap #> Spreadsheet author: gspreadr -#> Date of googlesheets registration: 2015-07-01 07:27:55 GMT -#> Date of last spreadsheet update: 2015-07-01 07:27:53 GMT +#> Date of googlesheets registration: 2015-07-07 08:35:41 GMT +#> Date of last spreadsheet update: 2015-07-07 08:35:39 GMT #> visibility: private #> permissions: rw #> version: new @@ -722,8 +723,8 @@

Upload delimited files or Excel workbooks

#> Europe: 1000 x 26 #> Oceania: 1000 x 26 #> -#> Key: 11vPD6VdocD2yQZc_1LbmW8WScGc_8geuTBNL1LVh7RA -#> Browser URL: https://docs.google.com/spreadsheets/d/11vPD6VdocD2yQZc_1LbmW8WScGc_8geuTBNL1LVh7RA/ +#> Key: 19bplWnDxRtvR74k4mtAro9gu__ptLmgg2A9NCd-dkGk +#> Browser URL: https://docs.google.com/spreadsheets/d/19bplWnDxRtvR74k4mtAro9gu__ptLmgg2A9NCd-dkGk/ gap_xlsx %>% gs_read(ws = "Asia") #> Accessing worksheet titled "Asia" #> Source: local data frame [5 x 6] @@ -784,9 +785,9 @@

Authorization using OAuth2

user_session_info <- gs_user()
 #>           displayName: google sheets
 #>          emailAddress: gspreadr@gmail.com
-#>                  date: 2015-07-01 07:26:46 GMT
+#>                  date: 2015-07-07 08:34:17 GMT
 #>          access token: valid
-#>  peek at access token: ya29....vBXHQ
+#>  peek at access token: ya29....TG2XQ
 #> peek at refresh token: 1/zNh...ATCKT
 user_session_info
 #> $displayName
@@ -796,13 +797,13 @@ 

Authorization using OAuth2

#> [1] "gspreadr@gmail.com" #> #> $date -#> [1] "2015-07-01 07:26:46 GMT" +#> [1] "2015-07-07 08:34:17 GMT" #> #> $token_valid #> [1] TRUE #> #> $peek_acc -#> [1] "ya29....vBXHQ" +#> [1] "ya29....TG2XQ" #> #> $peek_ref #> [1] "1/zNh...ATCKT"
diff --git a/vignettes/basic-usage.md b/vignettes/basic-usage.md index 0271973..bca1210 100644 --- a/vignettes/basic-usage.md +++ b/vignettes/basic-usage.md @@ -21,31 +21,31 @@ The `gs_ls()` function returns the sheets you would see in your Google Sheets ho ```r (my_sheets <- gs_ls()) -#> Source: local data frame [41 x 10] +#> Source: local data frame [42 x 10] #> #> sheet_title author perm version updated -#> 1 Copy of Twitter Archive… joannazhaoo r new 2015-07-01 07:24:25 -#> 2 gas_mileage woo.kara r new 2015-07-01 02:21:07 -#> 3 for_sean gspreadr rw new 2015-06-23 18:33:10 -#> 4 TAGS v6.0ns m.hawksey r new 2015-06-22 19:17:33 -#> 5 EasyTweetSheet - Shared m.hawksey r new 2015-06-18 16:07:23 -#> 6 Supervisor Interests (R… silwood.mast… r new 2015-06-08 08:59:51 -#> 7 Projects_2013_14 david.orme r new 2015-06-08 08:59:44 -#> 8 Craigslist Lost & Found joannazhaoo r new 2015-06-01 22:35:04 -#> 9 #rhizo15 #tw m.hawksey r new 2015-06-01 15:41:47 -#> 10 Ari's Anchor Text Scrap… anahmani r new 2015-05-29 07:18:48 +#> 1 Copy of Twitter Archive… joannazhaoo r new 2015-07-07 08:31:25 +#> 2 gas_mileage woo.kara r new 2015-07-07 00:19:42 +#> 3 test-gs-jenny-121c66d79… gspreadr rw new 2015-07-06 17:08:26 +#> 4 Tweet Collector (TAGS v… gspreadr rw new 2015-07-01 13:43:14 +#> 5 #TalkPay Tweets iskaldur r new 2015-07-01 08:06:22 +#> 6 for_sean gspreadr rw new 2015-06-23 18:33:10 +#> 7 TAGS v6.0ns m.hawksey r new 2015-06-22 19:17:33 +#> 8 EasyTweetSheet - Shared m.hawksey r new 2015-06-18 16:07:23 +#> 9 Supervisor Interests (R… silwood.mast… r new 2015-06-08 08:59:51 +#> 10 Projects_2013_14 david.orme r new 2015-06-08 08:59:44 #> .. ... ... ... ... ... #> Variables not shown: sheet_key (chr), ws_feed (chr), alternate (chr), self #> (chr), alt_key (chr) # (expect a prompt to authenticate with Google interactively HERE) my_sheets %>% glimpse() -#> Observations: 41 +#> Observations: 42 #> Variables: -#> $ sheet_title (chr) "Copy of Twitter Archiver v2.1", "gas_mileage", "f... -#> $ author (chr) "joannazhaoo", "woo.kara", "gspreadr", "m.hawksey"... -#> $ perm (chr) "r", "r", "rw", "r", "r", "r", "r", "r", "r", "r",... +#> $ sheet_title (chr) "Copy of Twitter Archiver v2.1", "gas_mileage", "t... +#> $ author (chr) "joannazhaoo", "woo.kara", "gspreadr", "gspreadr",... +#> $ perm (chr) "r", "r", "rw", "rw", "r", "rw", "r", "r", "r", "r... #> $ version (chr) "new", "new", "new", "new", "new", "new", "new", "... -#> $ updated (time) 2015-07-01 07:24:25, 2015-07-01 02:21:07, 2015-06... +#> $ updated (time) 2015-07-07 08:31:25, 2015-07-07 00:19:42, 2015-07... #> $ sheet_key (chr) "1DoMXh2m3FGPoZAle9vnzg763D9FESTU506iqWkUTwtE", "1... #> $ ws_feed (chr) "https://spreadsheets.google.com/feeds/worksheets/... #> $ alternate (chr) "https://docs.google.com/spreadsheets/d/1DoMXh2m3F... @@ -80,7 +80,7 @@ gap <- gs_title("Gapminder") gap #> Spreadsheet title: Gapminder #> Spreadsheet author: gspreadr -#> Date of googlesheets registration: 2015-07-01 07:26:48 GMT +#> Date of googlesheets registration: 2015-07-07 08:34:20 GMT #> Date of last spreadsheet update: 2015-03-23 20:34:08 GMT #> visibility: private #> permissions: rw @@ -126,6 +126,9 @@ gap <- gap %>% gs_gs() #> Sheet successfully identifed: "Gapminder" ``` + + + The registration functions `gs_title()`, `gs_key()`, `gs_url()`, and `gs_gs()` return a registered sheet as a `googlesheet` object, which is the first argument to practically every function in this package. Likewise, almost every function returns a freshly registered `googlesheet` object, ready to be stored or piped into the next command. *We export a utility function, `extract_key_from_url()`, to help you get and store the key from a browser URL. Registering via browser URL is fine, but registering by key is probably a better idea in the long-run.* @@ -342,9 +345,9 @@ readfuns <- c("gs_read_csv", "gs_read_listfeed", "gs_read_cellfeed") readfuns <- sapply(readfuns, get, USE.NAMES = TRUE) sapply(readfuns, jfun) #> gs_read_csv gs_read_listfeed gs_read_cellfeed -#> user.self 0.031 0.136 0.989 -#> sys.self 0.002 0.014 0.046 -#> elapsed 1.308 1.719 3.339 +#> user.self 0.034 0.134 1.011 +#> sys.self 0.002 0.013 0.040 +#> elapsed 0.706 1.654 4.466 #> user.child 0.000 0.000 0.000 #> sys.child 0.000 0.000 0.000 ``` @@ -555,8 +558,8 @@ foo <- gs_new("foo") foo #> Spreadsheet title: foo #> Spreadsheet author: gspreadr -#> Date of googlesheets registration: 2015-07-01 07:27:15 GMT -#> Date of last spreadsheet update: 2015-07-01 07:27:13 GMT +#> Date of googlesheets registration: 2015-07-07 08:34:52 GMT +#> Date of last spreadsheet update: 2015-07-07 08:34:49 GMT #> visibility: private #> permissions: rw #> version: new @@ -565,8 +568,8 @@ foo #> (Title): (Nominal worksheet extent as rows x columns) #> Sheet1: 1000 x 26 #> -#> Key: 1E4R8x4fpHCozG3nc_AIN3xWPWGoR9SlKrTIRzLwH6HI -#> Browser URL: https://docs.google.com/spreadsheets/d/1E4R8x4fpHCozG3nc_AIN3xWPWGoR9SlKrTIRzLwH6HI/ +#> Key: 1Tg_XFZfvGTHWc-ZSgg5Ipjj4taZnjg_W5-nPsWAayVc +#> Browser URL: https://docs.google.com/spreadsheets/d/1Tg_XFZfvGTHWc-ZSgg5Ipjj4taZnjg_W5-nPsWAayVc/ ``` By default, there will be an empty worksheet called "Sheet1", but you can control it's title, extent, and initial data with additional arguments to `gs_new()` (see `gs_edit_cells()` in the next section). You can also add, rename, and delete worksheets within an existing sheet via `gs_ws_new()`, `gs_ws_rename()`, and `gs_ws_delete()`. Copy an entire spreadsheet with `gs_copy()`. @@ -615,9 +618,10 @@ foo <- foo %>% #> Sheet successfully identifed: "foo" #> Accessing worksheet titled "add_row" #> Worksheet "add_row" dimensions changed to 2 x 5. -## add the next 5 rows of data +## add the next 5 rows of data ... careful not to go too fast for(i in 2:6) { foo <- foo %>% gs_add_row(ws = "add_row", input = iris[i, ]) + Sys.sleep(0.3) } #> Row successfully appended. #> Row successfully appended. @@ -682,8 +686,8 @@ iris_ss <- gs_upload("iris.csv") iris_ss #> Spreadsheet title: iris #> Spreadsheet author: gspreadr -#> Date of googlesheets registration: 2015-07-01 07:27:50 GMT -#> Date of last spreadsheet update: 2015-07-01 07:27:47 GMT +#> Date of googlesheets registration: 2015-07-07 08:35:34 GMT +#> Date of last spreadsheet update: 2015-07-07 08:35:32 GMT #> visibility: private #> permissions: rw #> version: new @@ -692,8 +696,8 @@ iris_ss #> (Title): (Nominal worksheet extent as rows x columns) #> iris: 1000 x 26 #> -#> Key: 1Zw0L68up_wubuqAUiIOPB2N_OuhMfhbhZjrKd6XSQ70 -#> Browser URL: https://docs.google.com/spreadsheets/d/1Zw0L68up_wubuqAUiIOPB2N_OuhMfhbhZjrKd6XSQ70/ +#> Key: 13SkrPLW6QdKW4XduDXycp1TVtuW-UwSu2go2p6UbyoY +#> Browser URL: https://docs.google.com/spreadsheets/d/13SkrPLW6QdKW4XduDXycp1TVtuW-UwSu2go2p6UbyoY/ iris_ss %>% gs_read() #> Accessing worksheet titled "iris" #> Source: local data frame [5 x 5] @@ -717,8 +721,8 @@ gap_xlsx <- gs_upload(system.file("mini-gap.xlsx", package = "googlesheets")) gap_xlsx #> Spreadsheet title: mini-gap #> Spreadsheet author: gspreadr -#> Date of googlesheets registration: 2015-07-01 07:27:55 GMT -#> Date of last spreadsheet update: 2015-07-01 07:27:53 GMT +#> Date of googlesheets registration: 2015-07-07 08:35:41 GMT +#> Date of last spreadsheet update: 2015-07-07 08:35:39 GMT #> visibility: private #> permissions: rw #> version: new @@ -731,8 +735,8 @@ gap_xlsx #> Europe: 1000 x 26 #> Oceania: 1000 x 26 #> -#> Key: 11vPD6VdocD2yQZc_1LbmW8WScGc_8geuTBNL1LVh7RA -#> Browser URL: https://docs.google.com/spreadsheets/d/11vPD6VdocD2yQZc_1LbmW8WScGc_8geuTBNL1LVh7RA/ +#> Key: 19bplWnDxRtvR74k4mtAro9gu__ptLmgg2A9NCd-dkGk +#> Browser URL: https://docs.google.com/spreadsheets/d/19bplWnDxRtvR74k4mtAro9gu__ptLmgg2A9NCd-dkGk/ gap_xlsx %>% gs_read(ws = "Asia") #> Accessing worksheet titled "Asia" #> Source: local data frame [5 x 6] @@ -823,9 +827,9 @@ The function `gs_user()` will print and return some information about the curren user_session_info <- gs_user() #> displayName: google sheets #> emailAddress: gspreadr@gmail.com -#> date: 2015-07-01 07:26:46 GMT +#> date: 2015-07-07 08:34:17 GMT #> access token: valid -#> peek at access token: ya29....vBXHQ +#> peek at access token: ya29....TG2XQ #> peek at refresh token: 1/zNh...ATCKT user_session_info #> $displayName @@ -835,13 +839,13 @@ user_session_info #> [1] "gspreadr@gmail.com" #> #> $date -#> [1] "2015-07-01 07:26:46 GMT" +#> [1] "2015-07-07 08:34:17 GMT" #> #> $token_valid #> [1] TRUE #> #> $peek_acc -#> [1] "ya29....vBXHQ" +#> [1] "ya29....TG2XQ" #> #> $peek_ref #> [1] "1/zNh...ATCKT"