How to extract a string from a variable based on its first letter

Code examples

0
0

extract first element before a character stringr

library(stringr)

df1 <- read.table(text = "ABC|DEF|GHI, ABCD|EFG|HIJK,  ABCDE|FGHI|JKL,  
                         DEF|GHIJ|KLM, GHI|JKLM|NO|PQRS, BCDE|FGHI|JKL")
#extract 1st word before |
word(df1$V1,1,sep = "\\|")

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................