sort.bstr: sort bstr

Description Usage Arguments Examples

View source: R/general.R

Description

sort bstr

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## S3 method for class 'bstr'
sort(x, decreasing = FALSE, ..., by = c("names", "length"))

bstr_sort(
  bstrobj,
  by = c("names", "length"),
  decreasing = FALSE,
  na_last = TRUE,
  numeric = TRUE
)

bstr_sort_subname(
  bstrobj,
  pattern,
  start,
  end,
  decreasing = FALSE,
  na_last = TRUE,
  numeric = TRUE
)

Arguments

x

x

decreasing

A boolean. If FALSE, the default, sorts from lowest to highest; if TRUE sorts from highest to lowest.

...

...

by

sort bstr object by c("names", "length")

bstrobj

bstr class object or character vector

na_last

Where should NA go? TRUE at the end, FALSE at the beginning, NA dropped.

numeric

If TRUE, will sort digits numerically, instead of as strings.

pattern

regular expression to extract substrings of the name to sort

start

start position to extract substrings of the name

end

end position to extract substrings of the name

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
test <- bstr_rand_seq(6, c(10, 5, 10, 12, 13, 3), seed = 1)
test
sort(test, decreasing = TRUE)
sort(test, by = "length")

names(test) <- c("test1", "test10", "test10", "test20", "test3", "test100")
sort(test)

bstr_sort(test)
bstr_sort_subname(test, "test.")
bstr_sort_subname(test, start = 1, end = 4)

t-arae/bstringr documentation built on March 18, 2021, 3:08 a.m.