Sort value labels according to values or to labels
sort_val_labels(x, according_to = c("values", "labels"), decreasing = FALSE) # S3 method for haven_labelled sort_val_labels(x, according_to = c("values", "labels"), decreasing = FALSE) # S3 method for data.frame sort_val_labels(x, according_to = c("values", "labels"), decreasing = FALSE)
| x | A labelled vector. |
|---|---|
| according_to | According to values or to labels? |
| decreasing | In decreasing order? |
#> <Labelled double> #> [1] 1 2 3 #> #> Labels: #> value label #> 2 maybe #> 1 yes #> 3 nosort_val_labels(v)#> <Labelled double> #> [1] 1 2 3 #> #> Labels: #> value label #> 1 yes #> 2 maybe #> 3 nosort_val_labels(v, decreasing = TRUE)#> <Labelled double> #> [1] 1 2 3 #> #> Labels: #> value label #> 3 no #> 2 maybe #> 1 yessort_val_labels(v, 'l')#> <Labelled double> #> [1] 1 2 3 #> #> Labels: #> value label #> 2 maybe #> 3 no #> 1 yessort_val_labels(v, 'l', TRUE)#> <Labelled double> #> [1] 1 2 3 #> #> Labels: #> value label #> 1 yes #> 3 no #> 2 maybe