[R] Reduce(paste, x) question

Greg Snow 538280 at gmail.com
Thu Nov 1 20:50:24 CET 2012


It is not clear exactly what you want.

Do you want the final object to be a matrix with 2 columns (or the
number of columns equal to the number of items in the list?  If so you
could just use do.call(cbind, x) and you would not need reduce or
paste (paste is the wrong tool unless you want a single string with
the different things pasted into it).

Do you want a list with each element of the list being a vector?

Do you want a string, but with quotes inside the string?

Something else?

On Thu, Nov 1, 2012 at 12:47 PM, mdvaan <mathijsdevaan at gmail.com> wrote:
> I have a question about the Reduce function:
>
> x <- list()
> x[[1]] <- LETTERS[1:5]
> x[[2]] <- LETTERS[11:15]
> Reduce(paste, x)
> [1] "A K" "B L" "C M" "D N" "E O"
>
> How do I get this?:
> [1] "A" "K"
> [2] "B" "L"
> [3] "C" "M"
> [4] "D" "N"
> [5] "E" "O"
>
> Thanks for your help!
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Reduce-paste-x-question-tp4648151.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com




More information about the R-help mailing list