In R, you can split a string by comma using the strsplit
function.
In this example,
str
with a value containing commas.strsplit
function to split the string into a list of substrings using comma as the delimiter.str <- 'apple,banana,orange'
substrings <- unlist(strsplit(str, ','))
print(substrings)
[1] "apple" "banana" "orange"
In this tutorial, we learned How to Split a String by Comma in R language with well detailed examples.