我试图将来自Apple导出的时代系列数据转换成xts格式。但是,我无法获得正确的数据格式。
new = health_df %>% mutate( Type = str_remove(type, "HKQuantityTypeIdentifier"), Value = as.numeric(as.character(value)), Date = as_datetime(creationDate)) %>% filter(Type == 'HeartRate') %>% select(Date, Type, Value)
> head(new) # A tibble: 6 x 3 Date Type Value <dttm> <chr> <dbl> 1 2021-07-27 13:12:32 HeartRate 80 2 2021-07-27 13:12:38 HeartRate 79 3 2021-07-27 13:12:42 HeartRate 76 4 2021-07-27 13:12:47 HeartRate 73 5 2021-07-27 13:12:52 HeartRate 71