From a dataframe I get a character vector of a column by: arrange by date, time and group_by date
fall_hc %>% arrange(a_dat,AZeit) %>% group_by(a_dat) %>%
mutate(time_vec = str_c(snzeit,collapse= ",")) %>%
ungroup() %>%
filter(!is.na(time_vec))
This results in character vectors like:
x <- c("5, 31, 16, 64, 9, 10, 31")
I need a numeric vector from this x within a dataframe:
5 31 16 64 9 10 31.
because I want to calculate diff(x): 26 -15 48 -55 1 21.
and further process this to calculate the number of negativ differences.
Here are some data:
tibble::tribble(
~a_dat, ~AZeit, ~snzeit,
"2019-01-02", "24180", 31,
"2019-01-02", "24360", 27,
"2019-01-02", "24480", 16,
"2019-01-02", "24780", 64,
"2019-01-02", "30420", 9,
"2019-01-02", "30840", 10,
"2019-01-02", "35280", 31,
"2019-01-03", "24120", 40,
"2019-01-03", "24120", 27,
"2019-01-03", "24480", 6,
"2019-01-03", "24480", 4,
"2019-01-03", "24780", 9,
"2019-01-03", "25380", 25,
"2019-01-03", "26460", 33,
"2019-01-04", "24000", 5,
"2019-01-04", "24360", 2,
"2019-01-04", "24900", 1,
"2019-01-04", "27180", 29,
"2019-01-04", "30600", 8,
"2019-01-07", "24780", 25,
"2019-01-07", "24840", 4,
"2019-01-07", "28920", 3,
"2019-01-07", "31620", 11,
"2019-01-08", "24060", 46,
"2019-01-08", "24480", 7,
"2019-01-08", "25260", 4,
"2019-01-08", "27900", 5,
"2019-01-08", "29820", 5,
"2019-01-08", "30060", 74,
"2019-01-08", "33360", 5,
"2019-01-08", "33600", 28,
"2019-01-08", "34200", 15,
"2019-01-08", "35520", 13,
"2019-01-08", "36000", 19,
"2019-01-08", "44100", 24
)
They are already sorted, so you can leave out %>% arrange(a_dat,AZeit).
To clarify the purpose: I need to know how the operations are sorted with respect to snzeit, thats the time from cut to suture. Want to identify those days where they are sorted from short to long.
as.numericbeforediffsnzeitcolumn ?