| bind | R Documentation |
sftime objectsBind rows (features) of sftime objects
Bind columns (variables) of sftime objects
## S3 method for class 'sftime'
rbind(..., deparse.level = 1)
## S3 method for class 'sftime'
cbind(..., deparse.level = 1, sf_column_name = NULL, tc_column_name = NULL)
... |
Objects to bind; note that for the |
deparse.level |
An integer value; see |
sf_column_name |
Character value; specifies the active geometry column;
passed on to |
tc_column_name |
Character value; specifies active time column; passed
on to |
Both rbind and cbind have non-standard method dispatch
(see cbind): the rbind or cbind method for
sftime objects is only called when all arguments to be combined are of
class sftime.
If you need to cbind e.g. a data.frame to an sf,
use data.frame directly and use st_sftime on its
result, or use bind_cols; see examples.
rbind combines all sftime objects in ...
row-wise and returns the combined sftime object.
cbind combines all sftime objects in ...
column-wise and returns the combined sftime object. When called with
multiple sftime objects warns about multiple time and geometry columns
present when the time and geometry columns to use are not specified by using
arguments tc_column_name and sf_column_name; see also
st_sftime.
g1 <- st_sfc(st_point(1:2))
x1 <- st_sftime(a = 3, geometry = g1, time = Sys.time())
g2 <- st_sfc(st_point(c(4, 6)))
x2 <- st_sftime(a = 4, geometry = g2, time = Sys.time())
rbind(x1, x2) # works because both tc1 and tc2 have the same class
## Not run:
st_time(x2) <- 1
rbind(x1, x2) # error because both tc1 and tc2 do not have the same class
## End(Not run)
cbind(x1, x2)
if (require(dplyr)) {
# returns a data frame because names of sf and time column are modified:
dplyr::bind_cols(x1, x2)
# returns an sf object because the name of the time column is modified:
dplyr::bind_cols(x1, x2 %>% sf::st_drop_geometry())
# returns an sftime object because names of sf and time column are both
# preserved:
dplyr::bind_cols(x1, x2 %>% st_drop_time() %>% sf::st_drop_geometry())
}
df <- data.frame(x = 3)
st_sftime(data.frame(x1, df))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.