[R] How to multiply all dataframe rows by another dataframe's columns

2007-08-29 Thread Luke Neraas
Hello, I have two data frames, X and Y, with two columns each and different numbers of rows. # creation of data frame X Loc1.alleles - c(1,5,6,7,8) Loc1.Freq- c(0.35, 0.15, 0.05, 0.10, 0.35) Loc1 - cbind( Loc1.alleles,Loc1.Freq) X- data.frame(Loc1) #creation

Re: [R] How to multiply all dataframe rows by another dataframe's columns

2007-08-29 Thread Anders Nielsen
matrix(Y[,2]%o%X[,2],ncol=1) On Wednesday 29 August 2007 03:21 pm, Luke Neraas wrote: Hello, I have two data frames, X and Y, with two columns each and different numbers of rows. # creation of data frame X Loc1.alleles - c(1,5,6,7,8) Loc1.Freq- c(0.35, 0.15, 0.05,

Re: [R] How to multiply all dataframe rows by another dataframe's columns

2007-08-29 Thread Moshe Olshansky
Below is one way to do this: Loc1.alleles - c(1,5,6,7,8) Loc1.Freq- c(0.35, 0.15, 0.05, 0.10, 0.35) Loc1 - cbind( Loc1.alleles,Loc1.Freq) X- data.frame(Loc1) Loc2.alleles - c(1,4,6,8) Loc2.Freq - c(0.35, 0.35, 0.10, 0.20) Loc2 -