Separating text into lines

Asked

Viewed 38 times

1

I have a variable named STATUS where the answers are inserted like this:

IDENTIFICADOR   ESTADO
1               MG / SP
2               RJ / BA

I need to adjust to:

IDENTIFICADOR   ESTADO
1                   MG
1                   SP
2                   RJ
2                   BA
  • What is going on? What you really hope will happen?

  • To me it’s pretty clear what he wants. Just separate a list into a column into rows, using the tidyr just do df <- separate_rows(df, ESTADO). Anything looks here at a complete example: https://tidyr.tidyverse.org/reference/separate_rows.html

  • But using tidyr it would keep the transponders while separating my status column?

  • df %>% mutate(STATE=strsplit(STATE, "/")) %>% unnest(STATE) CONSEGUI!!!!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.