Re: [R] function to calculate networkdays?

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Fri, 11 Apr 2008 08:46:29 -0300

Try:

networkdays <- function(start, end, holidays) {
dates <- seq(as.Date(start), as.Date(end), by="day")

if(missing(holidays))holidays <- 0 else holidays <- length(holidays) sum(as.numeric(format(dates, "%w") > 1)) - holidays }

networkdays("2008-04-01", "2008-04-30")

networkdays("2008-04-01", "2008-04-30", "2008-04-21")

On Thu, Apr 10, 2008 at 5:54 PM, tom soyer <tom.soyer_at_gmail.com> wrote:

> Hi,
>
> Does anyone know if R has a built-in function that is similar to Excel's
> NETWORKDAYS function? i.e., Returns the number of whole working days
> between
> two dates. Working days exclude weekends.
>
> Thanks,
>
> --
> Tom
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]


______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Received on Fri 11 Apr 2008 - 11:58:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Apr 2008 - 12:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive