tibble seems to render time as degrees

When rendered as a tibble, time comes out in degrees, minutes, and seconds notation when hh:mm:ss is expected. When the specific column is displayed, the output is the expected format. Bug or user error?

library(tidyverse)

paces <- as_tibble_col(c("00:05:07", "00:05:25", "00:05:34", 
                         "00:06:05", "00:06:08", "00:06:10", 
                         "00:06:20", "00:06:21") %>% 
                         hms::as_hms(), column_name = "pace")
paces
#> # A tibble: 8 x 1
#>   pace  
#>   <time>
#> 1 05'07"
#> 2 05'25"
#> 3 05'34"
#> 4 06'05"
#> 5 06'08"
#> 6 06'10"
#> 7 06'20"
#> 8 06'21"
paces$pace
#> 00:05:07
#> 00:05:25
#> 00:05:34
#> 00:06:05
#> 00:06:08
#> 00:06:10
#> 00:06:20
#> 00:06:21

Created on 2022-10-25 by the reprex package (v2.0.1)

I don't think it is either a bug or an error; I would call it a quirk. The class of the column is hms and difftime, as expected, and the underlying values are in seconds. Storing the same values in a vector does result in a, for me, normal display of the time, but the other characteristics are identical. I don't see that this will affect calculations in any way. Perhaps using ' and '' for minutes and seconds of time is common in New Zealand or wherever tibbles were born.

paces <- as_tibble_col(c("00:05:07", "00:05:25", "00:05:34", 
                          "00:06:05", "00:06:08", "00:06:10", 
                          "00:06:20", "00:06:21") %>% 
                          hms::as_hms(), column_name = "pace")
paces
# A tibble: 8 × 1
  pace  
  <time>
1 05'07"
2 05'25"
3 05'34"
4 06'05"
5 06'08"
6 06'10"
7 06'20"
8 06'21"
str(paces)
tibble [8 × 1] (S3: tbl_df/tbl/data.frame)
 $ pace: 'hms' num [1:8] 00:05:07 00:05:25 00:05:34 00:06:05 ...
  ..- attr(*, "units")= chr "secs"
class(paces$pace)
[1] "hms"      "difftime"
as.numeric(paces$pace)
[1] 307 325 334 365 368 370 380 381
 
VEC <- c("00:05:07", "00:05:25", "00:05:34", 
   "00:06:05", "00:06:08", "00:06:10", 
   "00:06:20", "00:06:21") %>% 
   hms::as_hms()
VEC
00:05:07
00:05:25
00:05:34
00:06:05
00:06:08
00:06:10
00:06:20
00:06:21
str(VEC)
 'hms' num [1:8] 00:05:07 00:05:25 00:05:34 00:06:05 ...
 - attr(*, "units")= chr "secs"
class(VEC)
[1] "hms"      "difftime"
as.numeric(VEC)
[1] 307 325 334 365 368 370 380 381

Perhaps you are correct and this works as designed. On the other hand, the Kiwi representation of time is hh:mm:ss (so says the wikipaedia) so I am leaning towards a rendering bug for tibble. You are correct that the rendering does not interfere with the use of the data, the structure is unchanged. I went back and tweaked the vector to make one of times include a non-zero hour ("03:05:25"), and, voila!, the rendering of the entire table is hh:mm:ss. I was hoping to see 03°05'25". It seems that the tibble is a bit inconsistent when it comes to rendering.

Though, I am happy to be wrong.

Please ignore this entry. I think my environment was somehow polluted. When I started a new environment, the rendering works as expected.

I'll look for the pollution, but I think this is user (me) error.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.