[R] Combining characters
Rui Barradas
ruipbarradas at sapo.pt
Wed Jan 4 21:03:36 CET 2012
Hello,
If you want to apply the same procedure to all elements of an object, check
out the '*apply' functions.
In this case,
x=c("one","two","three")
y=c("yellow","blue","green")
z=c("apple","cheese")
lapply(x, function(x) paste(x, y))
gives a good picture of what you want to do, just transform it into a
function and use the function:
f <- function(x, y) unlist(lapply(x, function(x) paste(x,y)))
f(x, f(y, z))
With more than 3 vectors, you could try a recursive version.
I hope this helps.
Rui Barradas
--
View this message in context: http://r.789695.n4.nabble.com/Combining-characters-tp4261888p4262632.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list