I am trying to create a two-way bar graph in r. Or a bar graph with two y-axis for different variables.
I have the following code:
x<-c("1820s", "1830s", "1840s", "1850s", "1860s", "1870s", "1880s", "1890s", "1900s")
y<- cbind(c(1.16, 1.36, 1.10, 1.16, 1.18, 1.19, 1.26, 1.32, 1.95)
y2<-c(58.71, 54.42, 39.36, 41.7, 51.14, 50.35, 59.53, 58.88, 75.31)
bp<-barplot(t(y), beside=TRUE)
xlim<-c(floor(min(bp)), ceiling(max(BP)))
par(new=TRUE)
However, from here, I'm not sure how to insert the second variable.
I would like for the format of my bargraph to look similar to this.