Luke Neraas
2007-Sep-19 00:15 UTC
[R] Create a loop to conduct multiple pairwise binary operations
#Hello, #I have three data frames, X,Y and Z with two columns each and different numbers of rows. # creation of data frame X X.alleles <- c(1,5,6,7,8) X.Freq <- c(0.35, 0.15, 0.05, 0.10, 0.35) Loc1 <- cbind( Loc1.alleles,Loc1.Freq) X <- data.frame(Loc1) #creation of data frame Y Y.alleles <- c(1,4,6,8) Y.Freq <- c(0.35, 0.35, 0.10, 0.20) Loc2 <- cbind(Loc2.alleles, Loc2.Freq) Y <- data.frame (Loc2) # creation of data frame Z Z.alleles <- c(1,4,5,6,8) Z.Freq <- c(0.35, 0.35, 0.05, 0.05, 0.20) Loc3 <- cbind(Loc3.alleles, Loc3.Freq) Z <- data.frame (Loc3) X Y Z # I want to create a pair wise multiplication for all of the second columns of my dataframe X,Y and Z # Here is a way to get two of the data frames to create a pairwise multiplication. X.Freq_times_Y.Freq<- matrix(Y[,2] %o% X[,2], ncol=1) X.Freq_times_Y.Freq # I would like to create a loop to calculate all possible pairwise multiplications for the # second columns of my X,Y, and Z data frames. # I will be conducting pair wise comparisons for up to 50 different data frames so I need the code to be # as flexible as possible Any help would be greatly appreciated. Thanks in advance Luke Neraas University of Alaska Fairbanks School of Fisheries and Ocean Sciences 11120 Glacier Highway UAF Fisheries Division Juneau, AK 99801 [[alternative HTML version deleted]]