Hello World,
I have a function that makes pairwise comparisons between two strings. I would 
like to apply this function to my data (which consists of columns with 
different strings) in the way that it compares the first with the second entry, 
and then the third with the fourth, and then the fifth with the sixth, and so 
on down each column...
So (2x-1) and (2x) would be the different entries to be compared!

dat= my data:

for the first column: compare dat[(2x-1),1] with dat[(2x),1] and x would be 
1:i, i=length(dat[,1])

I think the best way to do that is a loop:

a <- as.character(dat[(2x-1),1])
b <- as.character(dat[(2x),1])

for (i in 1:length(dat[,1]) my_function(a, b))

Can somebody help me to apply a function with a loop in the way I want to a 
column? Is there a specification of "tapply" for that?

Thank you very much,
Laetitia


----------------------------------------------------------------------------

Laetitia G. Schmid
Master Student of Evolutionary Genetics in Marine Mammals
Department of Genetics, Microbiology and Toxicology
Stockholm University
Svante Arrheniusväg 16
10691 Stockholm, Sweden

private:
Laetitia G. Schmid
c/o Von Ahn
Sköntorpsvägen 100
12053 Stockholm
Sverige

+46 70 651 0185

laeti...@gmt.su.se
______________________________________________
R-help@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.

Reply via email to