Datalink:
Code:
distevyield <- read.csv(file = "F:/Purdue University/RA_Position/PhD_ResearchandDissert/PhD_Draft/GTAP-CGE/GTAP_NewAggDatabase/NewFiles/GTAP_DistEVYield.csv", header=TRUE, sep=",", na.string="NA", dec=".", strip.white=TRUE)
str(distevyield)
distevyield <- as.data.frame(distevyield)
distevyield[5:6] <- sapply(distevyield[5:6],as.numeric)
distevyield <- droplevels(distevyield)
distevyield <- transform(distevyield,region=factor(region,levels=unique(region)))
library(ggplot2)
distevyield.f <- melt(subset(distevyield, region !="World"))
Figure3 <- ggplot(data = distevyield.f, aes(factor(variable), value))
Figure3 + geom_boxplot() +
theme(axis.text.x = element_text(colour = 'black', angle = 90, size = 15, hjust = 1, vjust = 0.5),axis.title.x = element_blank()) +
theme(axis.text.y = element_text(colour = 'black', size = 15, hjust = 0.5, vjust = 0.5), axis.title.y = element_blank()) +
theme(strip.text.x = element_text(size = 14, hjust = 0.5, vjust = 0.5, face = 'bold')) +
facet_wrap(~region, scales="free_y")
Outcome:
Question:
My two variables plotted, yield (%change) and ev (in million US$) have different units. Is there a way to add a secondary y-axis for one of the variable so as to display each variable with a boxplot representing its original units, but within the same plot? Does this feature exist in ggplot2 to begin with?
Thanks!