inbo / etn

R package to access data from the European Tracking Network
https://inbo.github.io/etn/
MIT License
6 stars 5 forks source link

Avoid arising warning in summary for empty projects in download_dataset() #141

Closed damianooldoni closed 3 years ago

damianooldoni commented 3 years ago

While trying to download data of a project, 2018_Iller, I get an additional warning at the end:

Warning messages:
1: In min.default(numeric(0), na.rm = FALSE) :
  no non-missing arguments to min; returning Inf
2: In max.default(numeric(0), na.rm = FALSE) :
  no non-missing arguments to max; returning -Inf

This is due to the fact that the project is empty, so no min or max date for detections can be returned:

message("* first date of detection:     ", detections %>% summarize(min(as.Date(.data$date_time))) %>% pull())
message("* last date of detection:      ", detections %>% summarize(max(as.Date(.data$date_time))) %>% pull())

I would fix it by adding a small if (nrow(detections) == 0) {}- else{} to embed these two lines of codes.

@peterdesmet: is it ok for you?

peterdesmet commented 3 years ago

Yes, good catch.

damianooldoni commented 3 years ago

Fixed together with #139 in https://github.com/inbo/etn/commit/1bace2b513c3fd007e834a9a970113764e9ca9a7

damianooldoni commented 3 years ago

@peterdesmet, this issue has been solved. We can close it, isn't?

peterdesmet commented 3 years ago

Yes indeed.