I am importing data from many .xlsx files to R. The problem is that in R the decimal numbers of the variables disappear, and it just shows the integer digits. Thanks for the help!
Example in .xlsx:
| date | weight | location | 
|---|---|---|
| 2022-01-01 00:00 | 30.12kg | xxxx | 
in R :
| date | weight | location | 
|---|---|---|
| 2022-01-01 00:00 | 30 | xxxx | 
How can I solve the problem?
Following my code
library(tidyverse)
dt <- list.files(path = "C:/Users/gim24gj/Documents/scales2022/data/raw/",
                 pattern = ".xlsx",
                 full.names = TRUE) %>%
  map_df(function(x) { 
    x %>% 
      read_xlsx(sheet = "5-minutely",
                cell_cols(c("A:B")),
                col_types = c("date","text")) %>% 
      select(time = 1, weight = 2) %>%
      mutate(id = paste(x)) %>% 
      mutate(id = str_extract(id, pattern = "([^\\/]+$)"),
             weight = as.numeric(str_extract(weight, "(\\d)+"))) %>% 
      select(id, time, weight) 
      
  })
