Splitting two columns does not work correctly or not at all

Hey all,

I have a big data frame with 10 variables and thousand of objectives and want to split the time stamp (which is the first column) into date and time.

I tried different codes so far, like the stringr and the tidyverse package, but all I get is two different results:

  1. nothing happens at all, but also no error code appears (for tidyverse)
  2. it splits the time stamp how I want it, but cuts of all the other columns, so I just have the date and time left (for stringr)
bubble_data %>%
  separate(Time, into = c('Date', 'Time'), sep = " ") %>%
str_split_fixed(bubble_data$Time," ", 2)

Thats the two codes I tried.

Thanks in advance.

Maybe it is because you forgot to save the results?

bubble_data = tibble(
  Time = c("01.01.2022 12:34",
           "02.01.2022 11:15",
           "03.01.2022 11:53"),
  Data1 = c(1,2,3),
  Data2 = c(494959, 228984, 258588)
)

bubble_data2 = bubble_data %>%
  separate(Time, into = c('Date', 'Time'), sep = " ")

bubble_data2

# A tibble: 3 x 4
  Date       Time  Data1  Data2
  <chr>      <chr> <dbl>  <dbl>
1 01.01.2022 12:34     1 494959
2 02.01.2022 11:15     2 228984
3 03.01.2022 11:53     3 258588

Oh god, I feel stupid. That was the only issue. Thanks man! :smile:

This topic was automatically closed 21 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.