Learn R Programming

greta (version 0.2.0)

extract-replace-combine: extract, replace and combine greta arrays

Description

Generic methods to extract and replace elements of greta arrays, or to combine greta arrays.

Arguments

i, j

indices specifying elements to extract or replace

value

a greta array to replace elements

...

either further indices specifying elements to extract or replace ([), or multiple greta arrays to combine (cbind(), rbind() & c()), or additional arguments (rep())

drop, recursive

generic arguments that are ignored for greta arrays

Usage

# extract
x[i]
x[i, j, ..., drop = FALSE]

# replace x[i] <- value x[i, j, ...] <- value

# combine cbind(...) rbind(...) c(..., recursive = FALSE) rep(x, times, ..., recursive = FALSE)

Examples

Run this code
# NOT RUN {
 x = as_data(matrix(1:12, 3, 4))

 # extract/replace
 x[1:3, ]
 x[, 2:4] <- 1:9

 # combine
 cbind(x[, 2], x[, 1])
 rbind(x[1, ], x[3, ])
 c(x[, 1], x)
 rep(x[, 2], times = 3)
# }

Run the code above in your browser using DataLab