GLEON / rLakeAnalyzer

An R version of Lake Analyzer
43 stars 26 forks source link

wtr.heat.map error "need finite 'xlim' values" from data & code that previously worked #112

Closed kiyokota closed 3 years ago

kiyokota commented 3 years ago

Hello. I was trying to make a step-by-step instruction for an undergrad student to re-generate water temp heat map with existing codes and data sets. They worked for me before (last used on 26 Mar 2019), but now I encounter the following error. I tried multiple old data files that I generated heat maps with rLakeAnalyzer before, whole ice-free season to just a few days, on two PCs with the latest versions of rLakeAnalyzer, R, and RStudio, with the same error.

winter2017.temp A tibble: 20,711 x 15 datetime wtr_1 wtr_2 wtr_3 wtr_4 wtr_5 wtr_6 wtr_7 wtr_8 wtr_9 wtr_10 wtr_12

1 2016-09-28 13:00:00 20.5 20.2 20.1 20.1 20.0 20.0 19.8 19.9 19.9 19.8 12.9 2 2016-09-28 13:15:00 20.3 20.2 20.1 20.1 20.0 20.0 19.8 19.9 19.9 19.8 12.7 3 2016-09-28 13:30:00 20.6 20.3 20.2 20.2 20.1 20.0 19.8 19.9 19.9 19.8 12.4 4 2016-09-28 13:45:00 20.5 20.3 20.1 20.1 20.0 20.0 19.8 19.9 19.9 19.8 12.3 5 2016-09-28 14:00:00 20.3 20.1 20.1 20.1 20.0 20.0 19.8 19.9 19.9 19.8 12.4 6 2016-09-28 14:15:00 20.5 20.3 20.1 20.2 20.1 20.0 19.8 19.9 19.9 19.8 12.3 7 2016-09-28 14:30:00 20.6 20.3 20.2 20.2 20.1 20.0 19.8 19.9 19.9 19.8 12.0 8 2016-09-28 14:45:00 20.5 20.3 20.2 20.2 20.1 20.0 19.8 19.9 19.9 19.8 11.8 9 2016-09-28 15:00:00 20.9 20.5 20.2 20.2 20.2 20.1 19.8 19.9 19.9 19.8 11.7 10 2016-09-28 15:15:00 20.3 20.1 20.1 20.1 20.0 19.9 19.8 19.9 19.9 19.8 11.6 ... with 20,701 more rows, and 3 more variables: wtr_13 , wtr_14 , wtr_15 wtr.heat.map(winter2017.temp) **Error in plot.window(xlim, ylim, "", xaxs = xaxs, yaxs = yaxs, asp = asp) : need finite 'xlim' values** In addition: Warning messages: 1: Unknown or uninitialised column: `y`. 2: Unknown or uninitialised column: `x`. 3: In min(x, na.rm = na.rm) : no non-missing arguments to min; returning Inf 4: In max(x, na.rm = na.rm) : no non-missing arguments to max; returning -Inf

The only way I could resolve this so far has been to export the data table as a tab-separated text file in ~/R/win-library/4.0/rLakeAnalyzer/mydata, similar to the way the sample data file Sparkling.daily.wtr is stored in ~/R/win-library/4.0/rLakeAnalyzer/extdata.

Now this needs to be exported back to "mydata" folder as a new tab-separated text file named "winter2017". write.table(winterHOBO2017,'winter2017b', append = FALSE, sep = "\t", row.names = FALSE, quote=FALSE)

Specify the file path for the data file MyFilePath <- system.file('mydata', 'winter2017b', package="rLakeAnalyzer")

Load the data back into R winter2017b.temp = load.ts(MyFilePath) winter2017b.temp wtr.heat.map(winter2017b.temp, zlim = c(0,30) This worked

wtr. heat.map used to work directly with imported .csv files as long as 1) they were imported via readr in RStudio, and 2) the datetime column attribute was changed to datetime from the dropdown menu, Is there any way to work directly with .csv files as before?

Also plot.title argument within wtr.heat.map does not seem to be working even in the example: wtr.heat.map(sp.wtr, zlim=c(0,15), plot.title="Sparkling Water Temp (C)") Is there another package that I should load along with rLakeAnalyzer?

hdugan commented 3 years ago

Does this fix it? https://github.com/GLEON/LakeMetabolizer/issues/140

kiyokota commented 3 years ago

Yes, it worked as wtr.heat.map(as.data.frame(winter2017.temp, zlim = c(0,30), plot.title="5MP")) Thank you very much. plot.title still does not add a title, though - any tip on this?

hdugan commented 3 years ago

Try instead wtr.heat.map(as.data.frame(winter2017.temp), zlim = c(0,30), plot.title="5MP")

kiyokota commented 3 years ago

Still no title, unfortunately, but I realized that the parenthesis needs to be closed after winter2017.temp in order for the zlim argument to work.

Is plot.title dependent on another package? It is not working online at https://rdrr.io/cran/rLakeAnalyzer/man/wtr.heat.map.html, either: the second example with zlim = c(0.15) should have a title, but it does not appear.

hdugan commented 3 years ago

The plot.title argument is passed directly to graphics functions, however, I think this should work:

wtr.heat.map(as.data.frame(winter2017.temp), zlim = c(0,30), plot.title = title(main = "5MP"))

kiyokota commented 3 years ago

Yes, it worked! Thank you very much.