2012-04-01 10 views

Antwort

2

Von #[email protected]:

x<-letters[1:10]; mapply(function(y,z) paste(y,z), head(x, -1), tail(x, -1)) 
+1

Sie können die Funktion 'embed' auch in allgemeineren Situationen hilfreich finden. – joran

2

Schnell und schmutzig rufen ‚für‘ Schleife das zu tun Job:

foo <- function(a, b) { 
    print(a) 
    print(b) 
} 

a <- c('a', 'b', 'c', 'd') 

for (i in 1:(length(a)-1)) { 
    foo(a[i], a[i+1]) 
} 
Verwandte Themen