pacificclimate / climdex.pcic

Routines to compute ETCCDI Climdex indices
GNU General Public License v3.0
22 stars 13 forks source link

`climdexInput.csv()` fails to use fully formatted date columns #7

Closed jameshiebert closed 9 years ago

jameshiebert commented 9 years ago

The get.date.field() utility function used by climdexInput.csv() is supposed to take a set of date component columns, paste them together and then use the pasted dates to construct the climdexInput object.

However, there is a bug here https://github.com/pacificclimate/climdex.pcic/blob/master/R/climdex.r#L204 where if there is only one date field (e.g. a field that contains the full date in %Y-%m-%d format), R downgrades the return object to a vector and then do.call() fails.

The solution is simply to add the drop=FALSE argument to the indexing as such:

date.strings <- do.call(paste, input.data[,date.type$fields,drop=FALSE])