Hi Sandra,
Terribly ugly, but this way at least you don't have to know which years are
missing, etc.:
dat <- data.frame(year = c(1981,1984,1985,1986), size = c(1,2,3,4))
year_ <- data.frame(year = seq(1981,1986,1))
year_dat <- merge(year_, dat, by = "year", all=T)
na_s <- subset(year_dat, is.n
Hello everyone,
I have the following problem, I have a dataframes that looks like this:
fire$Year fire$Size
1 19811738.0
2 19842228.1
3 1985 38963.3
4 19862223.4
5 19873594.6
6 19881520.0
...
What I would like to do is copy the values from t
What you want to do is create a new dataframe that includes all the years.
> newdata <- data.frame( Year=1981:1988 )
> merge(fire, newdata, all=TRUE)
If you don't include the all=TRUE, then you only get the rows that are
contained in both datasets.
--
View this message in context:
http://r.789
3 matches
Mail list logo