## Set a temporal working directory and write input files:
wd <- tempdir()
wd0 <- setwd(wd)
## Load example daily precipitation data:
data(climatol_data)
dat <- as.matrix(RR3st[,2:4])
## Set zero precipitation in some days and years of two of the three stations:
x <- seq(as.Date('1981-01-01'),as.Date('1995-12-31'),1)
year <- as.integer(strftime(x,'%Y'))
wkd <- as.integer(strftime(x,'%w')) #weekday: 0(Sunday) to 6
dat[year%in%1986:1990 & wkd==6,1] <- 0
dat[year%in%1989:1992 & wkd%in%5:6,2] <- 0
write(dat,'Prec_1981-1995.dat') #write the input data file
## write stations input file:
write.table(SIstations,'Prec_1981-1995.est',row.names=FALSE,col.names=FALSE)
## Now run the function:
weekendaccum('Prec',1981,1995)
## Return to user's working directory:
setwd(wd0)
## Input and output files can be found in directory:
print(wd)
Run the code above in your browser using DataLab