csv2rwl function

Read Ring Width File from CSV

Read Ring Width File from CSV

This function reads in a file of ring widths (.rwl) from a text file with comma separated values (csv). UTF-8

csv2rwl(fname,...)

Arguments

  • fname: a character vector giving the file name of the csv file.
  • ...: other arguments passed to read.table.

Details

This is a simple wrapper to read.table that reads in a text file with ring-width data in "spreadsheet" format. I.e., with series in columns and the the years as rows. The first column should contain the years and each subsequent column should contain a tree-ring series. The series names should be in the first row of the file. The deafult for NA values are empty cells or as the character string "NA" but can also be set using the na.strings argument passed to read.table. E.g.,:

YearSer1ASer1BSer2ASer2B
1901NA0.450.430.24
1902NA0.050.000.07
19030.170.460.030.21
19040.280.210.540.41
19050.290.850.170.76
19060.560.640.560.31
19071.121.060.990.83
etc...

Note that this is a rudimentary convenience function that isn't doing anything sophisticated. It reads in a file, assigns the years to the row names and sets the class of the object to c("rwl","data.frame") which allows dplR to recognize it.

Although arguments can be passed to read.table, this is not designed to be a flexible function. As is the philosophy with dplR, modifying the code is easy should the user wish to read in a different style of text file (e.g., tab delimited). Typing csv2rwl at the R prompt will get the user started.

Returns

Function returns an object of class c("rwl", "data.frame") with the series in columns and the years as rows. The series ID s are the column names and the years are the row names.

Author(s)

Andy Bunn

See Also

read.rwl, read.table

Examples

library(utils) data(ca533) # write out a rwl file in a format that csv2rwl will understand tm <- time(ca533) foo <- data.frame(tm,ca533) # this is the temp file where foo will be written tmpName <- tempfile() write.csv(foo,file=tmpName,row.names=FALSE) # read it back in using csv2rwl bar <- csv2rwl(tmpName) # check to see if identical identical(ca533,bar) # delete temp file unlink(tmpName)