This works! Thanks very much! From: Mohammad Tanvir Ahamed [mailto:mashra...@yahoo.com] Sent: Wednesday, January 15, 2014 9:48 AM To: Yuan, Rebecca; R help Subject: Re: [R] How to get a substring from a string
Hi ! Try it st<-'yab~a+b+c' strsplit(st,"~")[[1]][1] Best regards ........................... Tanvir Ahamed Göteborg, Sweden ________________________________ From: "Yuan, Rebecca" <rebecca.y...@bankofamerica.com<mailto:rebecca.y...@bankofamerica.com>> To: R help <r-help@r-project.org<mailto:r-help@r-project.org>> Sent: Wednesday, 15 January 2014, 15:38 Subject: [R] How to get a substring from a string Hello all, I would like to get a substring (first few characters till ~) from a string I can think of way of doing so by > string<-'yab~a+b+c' > x<-substring(string,1,3) > x [1] "yab" But if I do not know the length of the first word before ~ sign, how can I get it out from the whole string? Thanks, Rebecca ---------------------------------------------------------------------- This message, and any attachments, is for the intended r...{{dropped:19}}
______________________________________________ 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.