Skip to content

Commit

Permalink
read.odf(): change name of 'header' in metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelley committed Jun 7, 2018
1 parent f2e95b9 commit 9667c71
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
34 changes: 19 additions & 15 deletions R/odf.R
Original file line number Diff line number Diff line change
Expand Up @@ -831,25 +831,29 @@ ODFListFromHeader <- function(header)
#' points(ctd[['salinity']][bad],ctd[['theta']][bad],col='red',pch=20)
#'
#' @param file the file containing the data.
#'
#' @param columns An optional \code{\link{list}} that can be used to convert unrecognized
#' data names to resultant variable names. For example,
#' \code{columns=list(salinity=list(name="salt", unit=list(unit=expression(), scale="PSS-78"))}
#' states that a short-name of \code{"salt"} represents salinity, and that the unit is
#' as indicated. This is passed to \code{\link{cnvName2oceName}} or \code{\link{ODFNames2oceNames}},
#' as appropriate, and takes precedence over the lookup table in that function.
#' @param header An indication of whether, or how, to store the
#' ODF file header within the \code{metadata} slot of the returned object.
#' There are three choices for \code{header}. (1) If it is \code{NULL},
#' the header is not stored in the \code{metadata} slot.
#'
#' @param header An indication of whether, or how, to store the entire
#' ODF file header in the \code{metadata} slot of the returned object.
#' There are three choices for the \code{header} argument.
#' (1) If it is \code{NULL}, then the ODF header is not stored in
#' the \code{metadata} slot (although some of its contents are).
#' (2) If it is \code{"character"}, the header is stored within
#' the \code{metadata} as \code{ODFHeader}, which is a vector of
#' character strings, one per line of the ODF file.
#' (3) If it is \code{"list"}, then \code{ODFHeader} in the
#' \code{metadata} slot of the returned object will be
#' a list comprising elements that are themselves lists of key-value
#' pairs. The naming of list entries follows that in the ODF header,
#' except that \code{\link{unduplicateNames}} is used to transform repeated names
#' by adding numerical suffices.
#' the \code{metadata} as a vector named \code{header}, comprising
#' a character string for each line of the header within the ODF file.
#' (3) If it is \code{"list"}, then the \code{metadata} slot of the
#' returned object will contain a \code{list} named \code{header} that
#' has lists as its entries. (The sub-lists are in the form of
#' key-value pairs.) The naming of list entries iis patterned on
#' that in the ODF header, except that \code{\link{unduplicateNames}}
#' is used to transform repeated names by adding numerical suffices.
#'
#' @template debugTemplate
#'
#' @return An object of class \code{oce}. It is up to a calling function to determine what to do with this object.
Expand Down Expand Up @@ -1172,11 +1176,11 @@ read.odf <- function(file, columns=NULL, header=NULL, debug=getOption("oceDebug"
model <- findInHeader("MODEL", lines)
res <- new("odf")
if (is.null(header)) {
res@metadata$ODFHeader <- NULL
res@metadata$header <- NULL
} else if (header == "character") {
res@metadata$ODFHeader <- lines[seq(1L, dataStart-1L)]
res@metadata$header <- lines[seq(1L, dataStart-1L)]
} else if (header == "list") {
res@metadata$ODFHeader <- ODFListFromHeader(lines[seq(1L, dataStart-1L)])
res@metadata$header <- ODFListFromHeader(lines[seq(1L, dataStart-1L)])
} else {
stop("problem decoding header argument; please report an error")
}
Expand Down
25 changes: 13 additions & 12 deletions man/read.odf.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9667c71

Please sign in to comment.