Learn R Programming

googlesheets (version 0.3.0)

gs_edit_cells: Edit cells

Description

Modify the contents of one or more cells. The cells to be edited are specified implicitly by a single anchor cell, which will be the upper left corner of the edited cell region, and the size and shape of the input. If the input has rectangular shape, i.e. is a data.frame or matrix, then a similarly shaped range of cells will be updated. If the input has no dimension, i.e. it's a vector, then byrow controls whether edited cells will extend from the anchor across a row or down a column.

Usage

gs_edit_cells(ss, ws = 1, input = "", anchor = "A1", byrow = FALSE,
  col_names = NULL, trim = FALSE, 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

anchor

single character string specifying the upper left cell of the cell range to edit; positioning notation can be either "A1" or "R1C1"

byrow

logical; should we fill cells across a row (byrow = TRUE) or down a column (byrow = FALSE, default); consulted only when input is a vector, i.e. dim(input) is NULL

col_names

logical; indicates whether column names of input should be included in the edit, i.e. prepended to the input; consulted only when length(dim(input)) equals 2, i.e. input is a matrix or data.frame

trim

logical; do you want the worksheet extent to be modified to correspond exactly to the cells being edited?

verbose

logical; do you want informative messages?

See Also

gs_add_row

Examples

Run this code
# NOT RUN {
yo <- gs_new("yo")
yo <- gs_edit_cells(yo, input = head(iris), trim = TRUE)
gs_read(yo)

yo <- gs_ws_new(yo, ws = "byrow_FALSE")
yo <- gs_edit_cells(yo, ws = "byrow_FALSE",
                    input = LETTERS[1:5], anchor = "A8")
gs_read_cellfeed(yo, ws = "byrow_FALSE", range = "A8:A12") %>%
  gs_simplify_cellfeed()

yo <- gs_ws_new(yo, ws = "byrow_TRUE")
yo <- gs_edit_cells(yo, ws = "byrow_TRUE", input = LETTERS[1:5],
                    anchor = "A8", byrow = TRUE)
gs_read_cellfeed(yo, ws = "byrow_TRUE", range = "A8:E8") %>%
  gs_simplify_cellfeed()

yo <- gs_ws_new(yo, ws = "col_names_FALSE")
yo <- gs_edit_cells(yo, ws = "col_names_FALSE", input = head(iris),
                    trim = TRUE, col_names = FALSE)
gs_read_cellfeed(yo, ws = "col_names_FALSE") %>%
  gs_reshape_cellfeed(col_names = FALSE)

gs_delete(yo)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab