range_text | R Documentation |
This function outputs the range of values (broken or continuous) as you would want to display it in text.
range_text(x, dash = "-", oxford = TRUE, sep = ", ", sep_last = "and ")
x |
A numeric vector of any length. Any duplicates will be removed. |
dash |
A string that will go between consecutive values in the string output. |
oxford |
Default = TRUE. Will only be used if the vector x provided is not continuous. Inherited from NMFSReports::text_list(). |
sep |
Default = ", ". Will only be used if the vector x provided is not continuous. Inherited from NMFSReports::text_list(). |
sep_last |
Default = "and ". Will only be used if the vector x provided is not continuous. Inherited from NMFSReports::text_list(). |
A string with the range of those values as might be included in a sentence ("1-3, 5, and 7-8").
# a typical example
x <- c(2003:2005, 2007, 2010:2012)
range_text(x)
# example has duplicate values out of order and specifies for a different dash and no oxford comma
x <- c(1,2,11,3,4,7,NA,8,3)
range_text(x, dash = "--", oxford = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.