0
I have a database about parties and on one line I have a series of acronym like: PT/PSDC/PCB/PMDB
. How do I select only the PMDB
within those lines?
0
I have a database about parties and on one line I have a series of acronym like: PT/PSDC/PCB/PMDB
. How do I select only the PMDB
within those lines?
1
You can do it:
partido<-c('PT/PSDC/PCB/PMDB')
library(stringr)
str_extract(partido,'PMDB')
This function extracts the first element found (in this case, only a unit of PMDB
). If there are several PMDB
s inside the vector, use str_extract_all
to extract all acronyms PMDB
:
str_extract_all(partido,'PMDB')
Browser other questions tagged r
You are not signed in. Login or sign up in order to post.
You need to post a sample from your database, so we can understand what kind of data we’re dealing with, without that information there’s no way to do anything.
– Thiago Fernandes