Hello, I guess the solution is rather simple but whatever I tried, I don't manage to get the result as I want to have it: I have several vectors of equal length in a list and I'd like to combine all first elements to a single string, all second elements to a single string, ..., all n-th elements to a single string. # Example code (how it should look like): t1 <- c(1,2,3) t2 <- c(3.4,5.5,1.1) paste(t1,t2, sep="\t") # and now how the data is available tl <- list(t1,t2) ??? what do I have to do to get the same output ??? Can anybody help me? Antje
try this: t1 <- c(1, 2, 3) t2 <- c(3.4, 5.5, 1.1) tl <- list(t1, t2) do.call("paste", c(tl, sep = "\t")) I hope it helps. Best, Dimitris Antje wrote:> Hello, > > I guess the solution is rather simple but whatever I tried, I don't > manage to get the result as I want to have it: > > I have several vectors of equal length in a list and I'd like to combine > all first elements to a single string, all second elements to a single > string, ..., all n-th elements to a single string. > > # Example code (how it should look like): > t1 <- c(1,2,3) > t2 <- c(3.4,5.5,1.1) > paste(t1,t2, sep="\t") > > # and now how the data is available > tl <- list(t1,t2) > ??? what do I have to do to get the same output ??? > > Can anybody help me? > > Antje > > ______________________________________________ > 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. >-- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014
Try this: paste(tl[[1]], tl[[2]], sep="\t") On Mon, Sep 22, 2008 at 11:08 AM, Antje <niederlein-rstat at yahoo.de> wrote:> Hello, > > I guess the solution is rather simple but whatever I tried, I don't manage > to get the result as I want to have it: > > I have several vectors of equal length in a list and I'd like to combine all > first elements to a single string, all second elements to a single string, > ..., all n-th elements to a single string. > > # Example code (how it should look like): > t1 <- c(1,2,3) > t2 <- c(3.4,5.5,1.1) > paste(t1,t2, sep="\t") > > # and now how the data is available > tl <- list(t1,t2) > ??? what do I have to do to get the same output ??? > > Can anybody help me? > > Antje > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O