[R] Reduce(paste, x) question
Sarah Goslee
sarah.goslee at gmail.com
Thu Nov 1 20:31:40 CET 2012
What is "this"? A matrix with two columns? A data frame? You did an
excellent job of providing data to reproduce your attempt so far;
thank you. But I'm not sure what you want as result. But maybe one of
these two things?
> data.frame(x, stringsAsFactors=FALSE)
c..A....B....C....D....E.. c..K....L....M....N....O..
1 A K
2 B L
3 C M
4 D N
5 E O
> matrix(unlist(x), ncol=2)
[,1] [,2]
[1,] "A" "K"
[2,] "B" "L"
[3,] "C" "M"
[4,] "D" "N"
[5,] "E" "O"
On Thu, Nov 1, 2012 at 2: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!
>
>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list