Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Merge dataset information same cell

I need to do a dataset merge but the information is in the same cell, how can I do it?

dati1<- c("a - Novara", "b - Torino", "c - Milano", "f - Bari")

dati2<- c("a", "b", "c", "f")

dat3 <- dati1<- c("Novara", "Torino", "Milano", "Bari")

result

tot <- data.frame(dati2, dat3)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

data.frame(do.call(rbind, strsplit(dati1, split = " - ")))

  X1     X2
1  a Novara
2  b Torino
3  c Milano
4  f   Bari

or with tidyr::separate:

separate(data.frame(dati1), col = dati1, into = str_c("col", 1:2))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading