googlesheets (version 0.1.0)

gs_add_row: Append a row to a spreadsheet

Description

Add a row to an existing worksheet within an existing spreadsheet. This is based on the https://developers.google.com/google-apps/spreadsheets/#working_with_list-based_feeds{list feed}, which has a strong assumption that the data occupies a neat rectangle in the upper left corner of the sheet. This function specifically uses https://developers.google.com/google-apps/spreadsheets/#adding_a_list_row{this method}, which "inserts the new row immediately after the last row that appears in the list feed, which is to say immediately before the first entirely blank row."

Usage

gs_add_row(ss, ws = 1, input = "", verbose = TRUE)

Arguments

ss
a registered Google spreadsheet, i.e. a googlesheet object
ws
positive integer or character string specifying index or title, respectively, of the worksheet
input
new cell values, as an object that can be coerced into a character vector, presumably an atomic vector, a factor, a matrix or a data.frame
verbose
logical; do you want informative messages?

Details

At the moment, this function will only work in a sheet that has a proper header row of variable or column names and at least one pre-existing data row. If you get Error : No matches, that suggests the worksheet doesn't meet these minimum requirements. In the future, we will try harder to populate the sheet as necessary, e.g. create default variable names in a header row and be able to cope with input being the first row of data.

See Also

gs_edit_cells

Examples

Run this code
yo <- gs_copy(gs_gap(), to = "yo")
yo <- gs_add_row(yo, ws = "Oceania",
                 input = c("Valinor", "Aman", "2015", "10000",
                           "35", "1000.5"))
tail(gs_read(yo, ws = "Oceania"))

gs_delete(yo)

Run the code above in your browser using DataLab