write.GLCdata {Rglimclim}R Documentation

Write an Rglimclim data file

Description

To convert a data frame into a data file of potential response variables, for input into the Rglimclim model fitting and simulation routines.

Usage

write.GLCdata(x, date.cols = 1:3, site.col = 4, data.cols, missval = -99.99, file, check.file = TRUE)

Arguments

x

A data frame containing a row for each day:site combination for which data are available. The data frame should contain columns for year (4-digit integer), month (2 digits), day (2 digits), site (4 characters) and data values (one column for each variable required). The 4-character site codes should match those defined in make.siteinfo or read.siteinfo - note in particular that alignment is important in case the codes contain leading or trailing spaces.

date.cols

A numeric vector of length 3, giving the numbers of the columns in x corresponding respectively to year, month and day of each observation. The default is 1:3.

site.col

A numeric scalar, giving the number of the column in x containing 4-character site codes (this will be converted to a character vector if it is not already one). The default is 4.

data.cols

A numeric vector giving the number(s) of the column(s) in x containing the data values to be written. The default is all columns except those defined in date.cols and site.col.

missval

The numeric value that will be used to replace any NA values in x (default -99.99). This is needed for compatibility with the underlying Fortran code which does not recognise a separate NA value.

file

Name of the output file.

check.file

If TRUE (the default), a check will be made to see if file already exists and, if so, the user will be asked whether they wish to overwrite the existing file. If FALSE, any existing file will be overwritten without warning.

Details

The GLCfit and GLCsim routines require data files in a tightly specified format, as described in the help for the data.file argument of the GLCfit routine). The present routine provides an easy way to generate them from an existing data frame in R.

Value

The routine returns a NULL value; its sole effect is to write the required data to file.

Note

This routine has not been tested extensively. Moreover, it may be slow and memory-intensive when writing very large datasets containing hundreds of thousands of cases for several variables. Finally: it is the user's responsibility to check that the rows of x are in chronological order - the routine does not check this (the model fitting and simulation routines will pick up any problems later, however).

Author(s)

Richard Chandler (richard@stats.ucl.ac.uk)

See Also

GLCfit.


[Package Rglimclim version 1.2-2 Index]