-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#' Format Months to One Letter Abbreviation | ||
#' | ||
#' Format long month name or integer formats to a single capital letter. Useful | ||
#' for plot scales as a way to save space. \code{f_month} is used for | ||
#' nominal data where as \code{f_number2month} is reserved for integers | ||
#' 1-12. | ||
#' | ||
#' @param x A vector of month names or integers 1-12. | ||
#' @return Returns a single letter month abbreviation atomic vector. | ||
#' @export | ||
#' @rdname f_month | ||
#' @examples | ||
#' f_month(month.name) | ||
#' f_number2month(1:12) | ||
f_month <- function(x) { | ||
toupper(gsub("(^.)(.+)", "\\1", as.character(x))) | ||
} | ||
|
||
|
||
#' @export | ||
#' @rdname f_month | ||
f_number2month <- function(x) { | ||
toupper(gsub("(^.)(.+)", "\\1", month.abb[x])) | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.