Re: [R] matrix math

From: Jack Tanner <ihok_at_hotmail.com>
Date: Thu 05 Jan 2006 - 09:56:26 EST


> I have 2 dataframes, temp1 and temp2.
>
> Each dataframe has 20 variables (&#147;cocolumns") and 525 observations
>(&#147;rows&#148;). 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.

>foo <- data.frame(c(1,1,1,1),c(2,2,2,2))
>bar <- data.frame(c(1,2,3,4),c(5,6,7,8))
>foo+bar

  c.1..1..1..1. c.2..2..2..2.

1             2             7
2             3             8
3             4             9
4             5            10

If your data frames are actually data frames, it should work.
>class(foo)

[1] "data.frame"



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:31:19 2006

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