write.crn {dplR}R Documentation

Write Tucson Format Chronology File

Description

This function writes a chronology to a Tucson (decadal) format file.

Usage

write.crn(crn, fname, header = NULL, append = FALSE)

Arguments

crn

a data.frame containing a tree-ring chronology with two columns of the type produced by chron. The first column contains the mean value chronology, the second column gives the sample depth. Years for the chronology are determined from the row names. The chronology ID is determined from the first column name.

fname

a character vector giving the file name of the crn file.

header

a list giving information for the header of the file. If NULL then no header information will be written.

append

logical flag indicating whether to append this chronology to an existing file.

Details

This writes a standard crn file as defined according to the standards of the ITRDB at https://www1.ncdc.noaa.gov/pub/data/paleo/treering/treeinfo.txt. This is the decadal or Tucson format. It is an ASCII file and machine readable by the standard dendrochronology programs. Header information for the chronology can be written according to the International Tree Ring Data Bank (ITRDB) standard. The header standard is not very reliable however and should be thought of as experimental here. Do not try to write headers using dplR to submit to the ITRDB. When submitting to the ITRDB, you can enter the metadata via their website. If you insist however, the header information is given as a list and must be formatted with the following:

Description Name Class Max Width
Site ID site.id character 6
Site Name site.name character 52
Species Code spp.code character 4
State or Country state.country character 13
Species spp character 18
Elevation elev character 5
Latitude lat character or numeric 5
Longitude long character or numeric 5
First Year first.yr character or numeric 4
Last Year last.yr character or numeric 4
Lead Investigator lead.invs character 63
Completion Date comp.date character 8

See examples for a correctly formatted header list. If the width of the fields is less than the max width, then the fields will be padded to the right length when written. Note that lat and long are really lat*100 or long*100 and given as integral values. E.g., 37 degrees 30 minutes would be given as 3750.

This function takes a single chronology with sample depth as input. This means that it will fail if given output from chron where prewhiten == TRUE. However, more than one chronology can be appended to the bottom of an existing file (e.g., standard and residual) with a second call to write.crn. However, the ITRDB recommends saving and publishing only one chronology per file. The examples section shows how to circumvent this. The output from this function might be suitable for publication on the ITRDB although the header writing is clunky (see above) and rwl files are much better than crn files in terms of usefulness on the ITRDB.

Value

fname

Author(s)

Andy Bunn. Patched and improved by Mikko Korpela.

See Also

chron, read.crn

Examples

library(utils)
data(ca533)
ca533.rwi <- detrend(rwl = ca533, method = "ModNegExp")
ca533.crn <- chron(ca533.rwi)
fname1 <- write.crn(ca533.crn, tempfile(fileext=".crn"))
print(fname1) # tempfile used for output

## Put the standard and residual chronologies in a single file
## with ITRDB header info on top. Not recommended.
ca533.crn <- chron(ca533.rwi, prewhiten = TRUE)
ca533.hdr <- list(site.id = "CAM", site.name = "Campito Mountain",
                  spp.code = "PILO", state.country = "California",
                  spp = "Bristlecone Pine", elev = "3400M", lat = 3730,
                  long = -11813, first.yr = 626, last.yr = 1983,
                  lead.invs = "Donald A. Graybill, V.C. LaMarche, Jr.",
                  comp.date = "Nov1983")
fname2 <- write.crn(ca533.crn[, -2], tempfile(fileext=".crn"),
                    header = ca533.hdr)
write.crn(ca533.crn[, -1], fname2, append = TRUE)
print(fname2) # tempfile used for output

unlink(c(fname1, fname2)) # remove the files

[Package dplR version 1.7.7 Index]