Re: [R] copy values from one dataframes into another

2011-02-23 Thread Scott Chamberlain
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

Re: [R] copy values from one dataframes into another

2011-02-23 Thread D Sonderegger
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