[R] matrix math

From: r user <ruser2006_at_yahoo.com>
Date: Thu 05 Jan 2006 - 09:39:45 EST


> I am using R 2.1.1 in an windows XP environment.
>
> I have 2 dataframes, temp1 and temp2.
>
> Each dataframe has 20 variables (“cocolumns") and
> 525 observations (“rows”). All variables are
> numeric.
>
> I want to create a new dataframe that also has 20
> columns and 525 rows. The values in this dataframe
> should be the sum of the 2 other dataframe.
>
> (i.e. temp1$column 1+temp2$column1,
> temp1$column2+temp2$column2, etc)
>
> What is the best/easiest way to accomplish this?
>
> Is I wish to "multiply" (instead of sum) the
> columns, how do I?
>
> I tried:
>
> temp3<-as.matrix(temp1)+as.matrix(temp2)
>
> I get the following error message: “Error in
> as.matrix(temp1) + as.matrix(temp2) :
> non-numeric argument to binary operator”
>
>
>
> ---------------------------------

> $16.99/mo. or less



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jan 05 10:25:52 2006

This archive was generated by hypermail 2.1.8 : Thu 05 Jan 2006 - 14:05:29 EST