Tengo los siguientes datos
datos <- read.table(text = 'col1
"ASDF3033121566984 UCA 199994"
"ASDF3033121566998 UCO Juan 129916"
"ASDF3033121567010 UGR 12199918"
"ASDF3033121567019 UCA Juan 121552520"
"9999999"
"ASDF3033121567064 UCA 1299524"
"ASDF3033121567082 Juan UCA 12199"
"ASDF3033121567120 UPO 12159543"
"9999999"
"ASDF3033121594373 USE 126"
"ASDF12345620629818 USE Juan 1206636 123456"
"ASDF12345620629991 UJA 1240 123456"
"ASDF12345620630178 UCO 12448 123456"
"ASDF12345620621526 UCO 12452 123456"
"ASDF12345620621831 Juan UCO 1206283 123456"
"ASDF12345620621909 UCO 126 123456"
', header = TRUE, stringsAsFactors = FALSE)
Quiero marcar en otra columna las siguientes letras
lista <- c("UCA","UCO","UGR","USE")
datos$col2 <- str_extract(datos$col1, lista)
Datos:
col1 col2
ASDF3033121566984 UCA 199994 UCA
ASDF3033121566998 UCO Juan 129916 UCO
ASDF3033121567010 UGR 12199918 UGR
ASDF3033121567019 UCA Juan 121552520 <NA>
9999999 <NA>
ASDF3033121567064 UCA 1299524 <NA>
ASDF3033121567082 Juan UCA 12199 <NA>
ASDF3033121567120 UPO 12159543 <NA>
9999999 <NA>
ASDF3033121594373 USE 126 <NA>
ASDF12345620629818 USE Juan 1206636 123456 <NA>
ASDF12345620629991 UJA 1240 123456 <NA>
ASDF12345620630178 UCO 12448 123456 <NA>
ASDF12345620621526 UCO 12452 123456 UCO
ASDF12345620621831 Juan UCO 1206283 123456 <NA>
ASDF12345620621909 UCO 126 123456 <NA>
¿Por qué algunas de las letras las extrae y otras no?