Learn R Programming

crn (version 1.1)

writeDataset: Create and save to disk a single variable dataset

Description

The daily and hourly files conatin many data elements Typically one works with a single variable at time. This function allows you to create subsets of data that have one and only one variable in the file. The monolithic file, of course, can be read with read.table. This function uses read.table, but skips the columns not requested and writes out the subset of data

Usage

writeDataset(filename, cnames = colnamesDaily, varname = "T_DAILY_MEAN")

Arguments

filename
Filename of the monolithic file. for example: CRN_Hourly_2011-09-19.dat or CRN_Daily_2011-09-19.dat. The function collateDaily for example will create a file of all stations and all variables and append a date stamp. this function reads that data and selects a single variable from the 35+ variables in the datasets
cnames
The column names either colnamesDaily or colnamesHourly It must match the file you are reading: hourly for hourly; daily for daily
varname
the variable you want to extract. It must be quoted exactly as it appears in the colnames constant

Value

requested.

Details

The function masks off all unnecessaru columns and writes a dataset. The station ID ( WBANNO) and date and time are also saved. one variable and one variable only is added to these base variables and output to the file

Examples

Run this code
 ## Not run: 
#  writeDataset(filename=CRN_Daily_2011-09-19.dat, 
#  cnames = colnamesDaily, varname = "T_DAILY_MEAN")
#  ## End(Not run)
  

Run the code above in your browser using DataLab