This function is mostly used to simplify the importing of csv and
text file in
openair. In particular it helps to get the
date or date/time into the correct format. The file can contain
either a date or date/time in a single column or a date in one
column and time in another.
import(file = file.choose(), file.type = "csv", sep = ",", header.at = 1, data.at = 2, date = "date", date.format = "%d/%m/%Y %H:%M", time = NULL, time.format = NULL, tzone = "GMT", na.strings = c("", "NA"), quote = "\"", ws = NULL, wd = NULL, correct.time = NULL, ...)
The name of the file to be imported. Default,
The file format, defaults to common ‘csv’ (comma delimited) format, but also allows ‘txt’ (tab delimited).
Allows user to specify a delimiter if not ‘,’ (csv) or TAB (txt). For example ‘;’ is sometimes used to delineate separate columns.
The file row holding header information or
The file row to start reading data from. When generating the data frame, the function will ignore all information before this row, and attempt to include all data from this row onwards.
Name of the field containing the date. This can be a date e.g. 10/12/2012 or a date-time format e.g. 10/12/2012 01:00.
The format of the date. This is given in ‘R’
format according to
The name of the column containing a time --- if there
is one. This is used when a time is given in a separate column and
If there is a column for
The time zone for the data. In order to avoid the
complexities of DST (daylight savings time), openair assumes the
data are in GMT (UTC) or a constant offset from GMT. Users can set
a positive or negative offset in hours from GMT. For example, to
set the time zone of the data to the time zone in New York (EST, 5
hours behind GMT) set
Strings of any terms that are to be interpreted as missing (NA). For example, this might be “-999”, or “n/a” and can be of several items.
String of characters (or character equivalents) the imported file may use to represent a character field.
Name of wind speed field if present if different from
Name of wind direction field if present if different
from “wd” e.g.
Numerical correction (in seconds) for imported
Other arguments passed to
A data frame formatted for openair use.
The function uses
strptime to parse dates and
times. Users should consider the examples for use of these
The function can either deal with combined date-time formats
e.g. 10/12/1999 23:00 or with two separate columns that deal with
date and time. Often there is a column for the date and another
for hour. For the latter, the option
time.format = "%H"
should be supplied. Note that R considers hours 0 to 23. However,
if hours 1 to 24 are detected
import will correct the hours
import will also ensure wind speed and wind direction are
correctly labelled (i.e. "ws", "wd") if
Note that it is assumed that the input data are in GMT (UTC) format and in particular there is no consideration of daylight saving time i.e. where in the input data set an hour is missing in spring and duplicated in autumn.
Examples of use are given in the openair manual.