read.regiondef {Rglimclim}R Documentation

Defining (sub)region names

Description

read.regiondef is intended as a convenient way to read region definitions from old GLIMCLIM (rather than Rglimclim) definition files.

define.regions achieves the same thing, but taking its input directly from R objects.

Usage

read.regiondef(region.file, nhead = 19)
define.regions(names, codes = NULL)

Arguments

region.file

A file containing region codes and names, in the format specified in the Details section below. The file should contain two sections: a header containing nhead rows (which is ignored); and a section defining the individual regions.

nhead

Number of header rows in region.file. The default value of 19 is the number of header rows in regions.def files for previous versions of GLIMCLIM.

names

A character vector of region names, including an entry giving the name of the entire study area

codes

A numeric vector of region codes corresponding to the entries in names: region zero corresponds to the entire study area, and other (sub)regions should be numbered from 1 to nreg, where nreg is the number of subregions being defined. The default assumes that the first element of names gives the name for the entire study area, with subsequent elements giving names for regions 1 through nreg.

Details

The definition of regions is required solely for the simulation routines in Rglimclim, which offer the option to output summary information for separate regions. In particular, region information is ignored by the model fitting routines.

For the read.regiondef function, the structure of the region.file file is tightly specified (a Fortran 77 relic). After the header, each line of the file defines one region, and looks something like

NUMBER TEXT

where NUMBER is a 2-digit region code and TEXT is a name for the region. NUMBER occupies positions 1-5 of the line, and TEXT occupies the remainder. The first region - number 0 - always represents the entire study area and must be present. Subsequent (sub)regions must be numbered consecutively from 1 upwards.

Value

A data frame with two columns: Region (the region number, starting with zero) and Name (the region name).

Author(s)

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

Examples

require(Rglimclim)
##
##       Names defined via a character vector
##
region.names <- c("Ashdown Forest",
                  "Pooh and Piglet's side of the forest",
                  "Christopher Robin's side of the forest")
regions <- define.regions(region.names)
print(regions)
##
##       Alternative (if there is a valid regions.def file 
##       in the current working directory - uncomment to run
##       this version):
##
# regions <- read.regiondef("regions.def")

[Package Rglimclim version 1.2-3 Index]