[R] copy values from one dataframes into another

saba Sa-Ba at gmx.net
Wed Feb 23 23:22:18 CET 2011


Hello everyone,

I have the following problem, I have a dataframes that looks like this:

  fire$Year fire$Size
1      1981    1738.0
2      1984    2228.1
3      1985   38963.3
4      1986    2223.4
5      1987    3594.6
6      1988    1520.0
...

What I would like to do is copy the values from the fire$Size colum and put
it into a new df but with "0" for the years that are missing. The result
should look like this:

year  size

1981  1738.0
1982      0
1983      0
1984  2228.1
...

First I tried to merge the two dataframes 
 temp <-merge(fire.sum,fire2, by.x="fire$Year", by.y="year")

but then it only gives me the years that are the same. So I thought it might
be easier to just copy them?

Any help is appreciated, thank you so much
Cheers
Sandra

-- 
View this message in context: http://r.789695.n4.nabble.com/copy-values-from-one-dataframes-into-another-tp3321805p3321805.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list