Here is the code that made the plot:
years <- c(1980, 1984, 1984, 1986, 1988)
pubs <- c("book","book","poem","poem","book")
mypubs <- data.frame(years,pubs)
counts <- table(mypubs$pubs,mypubs$years)
barplot(counts,main="pubs per year",xlab="year",col=c("darkblue","red"),legend=rownames(counts))
This is time-series data, and there is no data for 1981, 1982, 1983, 1985 and 1987. The data is whether I read a book or a poem at any given time.
Is there a straightforward way to take mypubs
and add holes for the missing years? I've tried doing a histogram plot, but I can't figure out how to make it reliably one bar for each year, and I can't figure out how to make a histogram do stacked colors.
data.frame
? – mtoto