[R] Question on applying vectors to data.frames by row

2006-11-13 Thread RDM
# Newbie alert # I am wanting to multiply the rows in a dataframe by a vector. # However, the default behavior appears to be for the vector to be applied # column wise. For example: vct - 1:4 df - data.frame(c1 = 5:10, c2= 6:11, c3=7:12, c4=8:13) multTheTwo - vct * df multTheTwo # This results

Re: [R] Question on applying vectors to data.frames by row

2006-11-13 Thread Gabor Grothendieck
Here are a couple of possibilities: as.data.frame(t(t(df) * vct)) df * rep(vct, each = nrow(df)) On 11/13/06, RDM [EMAIL PROTECTED] wrote: # Newbie alert # I am wanting to multiply the rows in a dataframe by a vector. # However, the default behavior appears to be for the vector to be