Re: [R] String manipulation, insert delim

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon, 18 Jun 2007 20:23:38 -0400

Try this:

> paste(read.fwf(textConnection(foo), bar, as.is = TRUE), collapse = ",")
[1] "have,a,nice,day"

On 6/18/07, Christopher Marcum <cmarcum_at_uci.edu> wrote:
> Hello All,
>
> I've been using R for two years now and I am happy to say this is the
> first time I could not find the answer to my problem in the R-help
> archives. Here is the pending problem:
>
> I want to be able to insert delimiters, say commas, into a string of
> characters at uneven intervals such that:
>
> foo<-c("haveaniceday")#my string of character
> bar<-c(4,1,4,3) # my vector of uneven intervals
>
> my.fun(foo,bar) # some function that places delimiters appropriately
>
> have,a,nice,day # what the function would ideally return
>
> I've tried multiple for-loops using cut and paste but have not had success.
>
> Thanks!
> Chris Marcum
> UCI Sociology
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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.
>



R-help_at_stat.math.ethz.ch 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. Received on Tue 19 Jun 2007 - 00:34:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 19 Jun 2007 - 01:32:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.