sqextract {tidysq} | R Documentation |
Extract parts of a sq object
Description
Operator to extract subsets of sq objects.
Arguments
x |
[ |
i , j , ... |
[ |
Details
This function follows vctrs-package
conventions
regarding argument interpretation for indexing vectors, which are a bit
stricter that normal R conventions, for example implicit argument recycling
is prohibited. Subsetting of the sq
object does not affect its
attributes (class and alphabet of the object). Attempt to extract elements
using indices not present in the object will return an error.
Value
sq
object of the same type as the input,
containing extracted elements
See Also
Functions from utility module:
==.sq()
,
get_sq_lengths()
,
is.sq()
,
sqconcatenate
Examples
# Creating object to work on:
sq_unt <- sq(c("AHSNLVSCTK$SH%&VS", "YQTVKA&#BSKJGY",
"IAKVGDCTWCTY>", "AVYI#VSV&*DVGDJCFA"))
# Subsetting using numeric vectors
# Extracting second element of the object:
sq_unt[2]
# Extracting elements from second to fourth:
sq_unt[2:4]
# Extracting all elements except the third:
sq_unt[-3]
# Extracting first and third element:
sq_unt[c(1,3)]
# Subsetting using logical vectors
# Extracing first and third element:
sq_unt[c(TRUE, FALSE, TRUE, FALSE)]
# Subsetting using empty vector returns all values:
sq_unt[]
# Using NULL, on the other hand, returns empty sq:
sq_unt[NULL]
[Package tidysq version 1.1.3 Index]