Created
February 13, 2014 17:13
-
-
Save cigrainger/8979392 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
prep.comp <- function(x){ | |
if (names(x)[1]!='Week'){ | |
stop("The first column should be 'Week'. Check the data.") | |
} | |
x[['Week']] <- as.character(x[['Week']]) | |
x[['weekstart']] <- strsplit(x[['Week']],split=' - ',fixed=TRUE)[[1]] | |
x[['weekend']] <- strsplit(x[['Week']],split=' - ',fixed=TRUE)[[2]] | |
x[['weekstart']] <- as.Date(x[['weekstart']],format='%Y-%m-%d') | |
x[['weekend']] <- as.Date(x[['weekend']],format='%Y-%m-%d') | |
return(x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment