Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vectorize dmonth #228

Open
ibarraespinosa opened this issue Jul 11, 2022 · 1 comment
Open

vectorize dmonth #228

ibarraespinosa opened this issue Jul 11, 2022 · 1 comment

Comments

@ibarraespinosa
Copy link
Member

currently, dmonth is not vectorized.

@ibarraespinosa
Copy link
Member Author

dmonth <- function(x) {

dmonth0 <- function(date) {
date <- as.Date(date, format = "%Y-%m-%d")
m <- format(date, format="%m")

while (format(date, format="%m") == m) {
date <- date + 1
}
return(as.integer(format(date - 1, format="%d")))
}
return(unlist(lapply(X = x, FUN = dmonth0)))

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant