Created
August 3, 2012 19:12
-
-
Save gsk3/3250534 to your computer and use it in GitHub Desktop.
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
#'Return a vector of the days of the week, in order | |
#' | |
#'@param start.day Day of the week to begin the week with (as a text item) | |
#'@return Character vector of length 7 | |
#'@examples | |
#'daysofweek("Sunday") | |
#' | |
daysofweek <- function(start.day="Monday") { | |
wkdays <- c('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday') | |
wkdays <- rep(wkdays,2) | |
selector <- unlist(lapply(wkdays,function(x) x==start.day)) #selects start day and one past end day | |
selector.numeric <- seq(length(wkdays))[selector] | |
selector.numeric[2] <- selector.numeric[2]-1 #Move to last day | |
return(wkdays[selector.numeric[1]:selector.numeric[2] ] ) | |
} | |
~~~~~~~~~~~~~~~~~~~~~~~ | |
> check("taRifx") | |
. | |
. | |
. | |
Running examples in 'taRifx-Ex.R' failed | |
The error most likely occurred in: | |
> assign(".ptime", proc.time(), pos = "CheckExEnv") | |
> ### Name: daysofweek | |
> ### Title: Return a vector of the days of the week, in order | |
> ### Aliases: daysofweek | |
> | |
> ### ** Examples | |
> | |
> daysofweek("Sunday") | |
Error: could not find function "daysofweek" | |
Execution halted | |
Error: Command failed (1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment