[R] String split and concatenation

Ista Zahn izahn at psych.rochester.edu
Wed Sep 29 07:26:49 CEST 2010


Hi Steven,
This should do it:

paste('"', unlist(strsplit(x, split="")), c(rep('",', length(x)-1), ""), sep="")

-Ista

On Wed, Sep 29, 2010 at 1:11 AM, Steven Kang <stochastickang at gmail.com> wrote:
> Hi R users,
>
>
> I desire to transform the following vector consisting of repeated characters
>
> x <- rep(letters, 3)
> into this exact format (i.e a single string containing each characters in
> quotation mark separated by comma between each; al ).
>
> ("a", "b", "c", "d", ........"a", "b", "c", "d", ..........., "a", "b", "c",
> "d", ........."z")
>
> Any advice would be much appreciated.
>
>
>
> --
> Steven
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org



More information about the R-help mailing list