[R] String concatenation

Andy Fugard a.fugard at ed.ac.uk
Sat Jun 28 13:44:48 CEST 2008


Hi,

Is the following function built in somewhere?

concat = function(v) {
   res = ""

   for (i in 1:length(v))
     res = paste(res,v[i],sep="")

   res
}

e.g.

 > concat(c("12","3","45"))
[1] "12345"

Cheers,

Andy

-- 
Andy Fugard, Postgraduate Research Student
Psychology (Room F3), The University of Edinburgh,
   7 George Square, Edinburgh EH8 9JZ, UK
Mobile: +44 (0)78 123 87190   http://www.possibly.me.uk

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the R-help mailing list