daily2climatol {climatol} | R Documentation |
Convert daily data files to climatol
input format
Description
This function can be useful to prepare the climatol
input files when the users have their daily data in per station individual files.
Usage
daily2climatol(stfile, stcol=1:6, datcol=1:4, varcli, anyi=NA, anyf=NA,
mindat=365, sep=',', dec='.', na.strings='NA', dateformat='%Y-%m-%d',
header=TRUE)
Arguments
stfile |
File with file names and station coordinates, codes and names. |
stcol |
Columns in |
datcol |
Columns in data files holding year, month, day, value. |
varcli |
Short name of the studied climatic variable. |
anyi |
First year to study (defaults to the first year of available data). |
anyf |
Last year to study (defaults to the last year of available data). |
mindat |
Minimum required number of data per station. (Defaults to 365 daily data.) |
sep |
Field separator in all files, whether data or stations. (',' by default.) |
dec |
Decimal point. ('.' by default.) |
na.strings |
Strings coding missing data ( |
dateformat |
Format of dates if not in separate columns. ( |
header |
Logical value indicating whether input files have a header line
or not. ( |
Details
Many users have their daily series in separate files (one per station). This
function can be used to read these daily data files and write the input files
needed by the homogen
function of this climatol
package.
When either station codes or names are missing in the stations file, its corresponding column must be set to 0. In this case, codes and/or names will be assigned with numeric values.
Field separator, decimal point and the presence of a header line must be consistent in all files (data files and stations file).
If your files follow the RClimDex convention, you can use the rclimdex2climatol
function instead.
See Also
Examples
## Set a temporal working directory and write example input files:
wd <- tempdir()
wd0 <- setwd(wd)
data(climatol_data)
df=cbind(File=c('p064.csv','p084.csv','p082.csv'),SIstations)
write.csv(df,'stations.csv',row.names=FALSE,quote=FALSE)
write.csv(p064.df,'p064.csv',row.names=FALSE,quote=FALSE)
write.csv(p084.df,'p084.csv',row.names=FALSE,quote=FALSE)
write.csv(p082.df,'p082.csv',row.names=FALSE,quote=FALSE)
## Now run the example:
daily2climatol(stfile='stations.csv',varcli='RR')
## Return to user's working directory:
setwd(wd0)
## Input and output files can be found in directory:
print(wd)