problem with time rstudio

I have a problem. I would like to insert an excel (csv.) data into r studio. everything is working, except the time. (i have data like 12:00, 13:30 etc.). When i insert this into R-Studio the time is not shown correct. (its written 0,9453, 0,4853, 0,8485).
whats the problem/command to solve this??

Please share your code (or reproducible example) with us, so we can help you.

2 Likes

r%20problem

on the right you see the excel version and on the left you see how it does come out on r studio
its just related to "zeit"

As @andresrcs noted, we really need a small reproducible example (aka a self-contained reprex ) to be sure, as it depends on how the times are stored in your file.

If they're strings, you might want to look at the hms package (part of the tidyverse, but not attached by default).

library(tidyverse)
dat <- tibble::tribble(
  ~record, ~time,
      "a",    "12:30",
      "b",     "1:45",
      "c",     "2:30"
  )
dat
#> # A tibble: 3 x 2
#>   record time 
#>   <chr>  <chr>
#> 1 a      12:30
#> 2 b      1:45 
#> 3 c      2:30

dat %>%
  mutate(time = hms::parse_hm(time))
#> # A tibble: 3 x 2
#>   record time  
#>   <chr>  <time>
#> 1 a      12:30 
#> 2 b      01:45 
#> 3 c      02:30

Created on 2018-11-30 by the reprex package (v0.2.1.9000)

See also several suggestions here:

For pointers on making a reprex, check out the reprex FAQ

Here's an example using a csv with similar data that I put into a gist:

library(readr)
dummy <- read_csv("https://gist.githubusercontent.com/batpigandme/868fcf6cfb3a0accf1ad6a7d0b52f4e7/raw/c3232afd7cb4c1d3b39022a230d4b23b5cbb9c6b/demo_csv.csv", 
                  col_types = cols(time = col_time(format = "%H:%M")))

dummy
#> # A tibble: 3 x 2
#>   record time  
#>   <chr>  <time>
#> 1 a      12:30 
#> 2 b      01:45 
#> 3 c      02:15

Created on 2018-11-30 by the reprex package (v0.2.1.9000)

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