ctmm-initiative / ctmm

Continuous-Time Movement Modeling. Functions for identifying, fitting, and applying continuous-space, continuous-time stochastic movement models to animal tracking data.
http://biology.umd.edu/movement.html
43 stars 10 forks source link

should the messages in importing data use less digits? #10

Closed xhdong-umd closed 7 years ago

xhdong-umd commented 7 years ago

This is a minor cosmetic issue. Currently the importing data process give messages with lots of digits after decimal point.

> data <- as.telemetry(gulls)
Maximum speed of 19.4395822947886 m/s observed in LBBG-Spiekeroog-2010-01
Minimum sampling interval of 3.05 minutes in LBBG-Spiekeroog-2010-01
Maximum speed of 19.8397782568591 m/s observed in LBBG-Spiekeroog-2010-02
Minimum sampling interval of 3.05 minutes in LBBG-Spiekeroog-2010-02
Maximum speed of 1512.12396281684 m/s observed in LBBG-Spiekeroog-2010-03
Minimum sampling interval of 3.05 minutes in LBBG-Spiekeroog-2010-03

Should we limit the digits after decimal points to maybe 2 or 4? Of course the significant digits will have higher priority for values like 0.00001 (or use scientific notation in that case).

xhdong-umd commented 7 years ago

sprintf looked to be better than format here

> sprintf("%.3f", 19.8397782568591)
[1] "19.840"
> format(0.123234231, nsmall = 3)
[1] "0.1232342"
> sprintf("%.3f", 0.123234231)
[1] "0.123"
chfleming commented 7 years ago

@xhdong-umd After playing around with sprintf and format, I like the digits option of format better because it allows me to set the number of significant digits, whereas %g in sprintf doesn't seem to allow that.

xhdong-umd commented 7 years ago

Yes, I just found format support digits and nsmall at the same time, and it can convert to scientific notification if needed, so it probably is the best option here.

> format(123123123.123124, digits = 7)
[1] "123123123"
> format(123123123.123124, digits = 7, nsmall = 3)
[1] "123123123.123"
> format(0.0000123124, digits = 7, nsmall = 3)
[1] "1.23124e-05"
> format(13242342342342.12, digits = 7, nsmall = 3)
[1] "1.324234e+13"
> format(0.123234231, digits = 7, nsmall = 3)
[1] "0.1232342"