Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

Splitting Strings

strsplit is used to split a string into substrings:

> unlist(strsplit("abc def ghi jkl", " "))
[1] "abc" "def" "ghi" "jkl"

> unlist(strsplit("abc,def:ghi.jkl", "\\.|,|:"))
[1] "abc" "def" "ghi" "jkl"

The split pattern is a regular expression (hence the \\. is required to quote the full stop).



Copyright © 2004-2006 Graham.Williams@togaware.com
Support further development through the purchase of the PDF version of the book.
Brought to you by Togaware.