parttime_extract | R Documentation |
Indexing operators repurpose matrix indexing for indexing into parttime
fields. When only i
is provided, the parttime
vector is sliced.
Whenever j
is provided, the individual fields are indexed out of an
internal matrix.
## S3 method for class 'partial_time'
x[i, j, ...]
## S3 method for class 'partial_time'
x[[i, j, ..., value]]
## S3 replacement method for class 'partial_time'
x[i, j, ..., reflow = TRUE] <- value
## S3 replacement method for class 'partial_time'
x[[i, ...]] <- value
x |
an object from which to extract element(s) or in which to replace element(s). |
i |
indicies specifying elements to extract or replace. For further details, see Extract. |
j |
column indicies specifying element(s) to extract or replace. For further details, see Extract. |
... |
arguments unused |
value |
typically an array-like R object of a similar class as
|
reflow |
a |
A numeric matrix subset of the partial_time
internal matrix
representation. See the Details section of parttime for further
information.
A numeric
vector of the provided parttime field
the new value of the assigned partial_time
object after
modification.
A partial_time
vector after modification
x <- as.parttime(c("2019", "2019-02", "2019-02-02"))
# <partial_time<YMDhms+tz>[3]>
# [1] "2019" "2019-02" "2019-02-02"
x[, c(1, 3)]
# year day
# 2019 2019 NA
# 2019-02 2019 NA
# 2019-02-02 2019 2
x[, "month"]
# 2019 2019-02 2019-02-02
# NA 2 2
x[, "month", drop = FALSE]
# month
# 2019 NA
# 2019-02 2
# 2019-02-02 2
x <- as.parttime(c("2019", "2019-02", "2019-02-02"))
# <partial_time<YMDhms+tz>[3]>
# [1] "2019" "2019-02" "2019-02-02"
x[c(1, 3)] <- as.parttime(c("2000", "1999"))
# <partial_time<YMDhms+tz>[3]>
# [1] "2000" "2019-02" "1999"
x[,"month"] <- 3
# <partial_time<YMDhms+tz>[3]>
# [1] "2000-03" "2019-03" "1999-03"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.