On 22 October 2007 at 00:43, Edna Bell wrote: | Hello R Gurus: | | I would like to take a character string and split at the $ sign. | | I thought that strsplit would do it, but here are the results: | | > vv | [1] "whine$ts1" | > vv | [1] "whine$ts1" | > strsplit(vv,"$") | [[1]] | [1] "whine$ts1" | | | Does anyone have any suggestions, please?
> strsplit(vv, "\\$") [[1]] [1] "whine" "ts1" > strsplit uses so-called regular expressions for which '$' is a meta-character, hence the need for 'escaping' it with a '\', which you then need to escape itself using a second '\'. There are numerous tutorials on regular expressions on the internet you may want to consult. The archives of this mailing also have dozens of posts on it. If you did not try RSiteSearch("strsplit") before posting to the list, consider doing it next time. Hth, Dirk -- Three out of two people have difficulties with fractions. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.