Reputation: 3034
I am looking for help to create multiple boxplots into one figure using the data below (see dropbox link).
Basically, I want to be able to plot the distribution of a selected variable (e.g. "ev") for a particular region (e.g. 'Mor') across all 'sres' scenarios using as an argument the factor 'tradlib'. Thus, the final result will be six boxplot each representing a 'tradlib' scenario for the selected variable and region.
Datalink https://www.dropbox.com/s/dt1nxnkhq90nea4/GTAP_Sims.csv
Upvotes: 0
Views: 620
Reputation: 118779
It would be great if the next time, if you also post what you had done and where you get stuck. Assuming your data.frame
is df
, this should get you started:
# boxplot for region = Mor
require(ggplot2)
df.f <- subset(df, region == "Mor")
# convert factor to character
df.f$ev <- as.character(df.f$ev)
# remove "," from ev using gsub and then convert to number
df.f$ev <- as.numeric(gsub(",", "", df.f$ev))
p <- ggplot(data = df.f, aes(factor(tradlib), ev))
p + geom_boxplot()
Upvotes: 1