3
I have this vector:
n <- c("alberto queiroz souza (alberto, q-s.)",
"alberto queiroz souza (alberto, queiroz souza)",
"alberto queiroz souza (alberto, q. s.)",
"alberto queiroz souza (alberto, q c)",
"bernardo josé silva (bernardo, j. s.)",
"bernardo josé silva (bernardo, j. silva)",
"josé césar pereira (josé, c. p.)",
"josé césar pereira (josé, c. pereira)")
For each element I would like to separate the name of the one in parentheses.
n <- str_split_fixed(as.character(n), " \\(", 2)
n <- c(strsplit(as.character(n), "\\)$"))
I don’t know how to do this split better
transforming into another vector with elements not duplicated.
result would be a vector like this:
result <- c("alberto queiroz souza",
"bernardo josé silva",
"josé césar pereira",
"alberto, q-s.",
"alberto, queiroz souza",
"alberto, q. s." ...... )