Commit 95051724 authored by Nicolau Manubens's avatar Nicolau Manubens
Browse files

Improved a2nc to store data types properly.

parent 9ef0bcf8
......@@ -209,7 +209,15 @@ ArrayToNc <- function(arrays, file_path) {
var_info[['longname']] <- var_info[['longname']][1]
}
if (!('prec' %in% names(var_info))) {
var_info[['prec']] <- 'float'
if (typeof(arrays[[i]]) == 'logical') {
var_info[['prec']] <- 'short'
} else if (typeof(arrays[[i]]) == 'character') {
var_info[['prec']] <- 'char'
} else if (typeof(arrays[[i]]) == 'integer') {
var_info[['prec']] <- 'integer'
} else {
var_info[['prec']] <- 'double'
}
} else {
if (!is.character(var_info[['prec']])) {
stop("The provided 'prec' for the ", j, "th variable in the ", i, "th array must be a character string.")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment