0

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

1 Answer 1

1

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()

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you very much and I will heed your advice next time :)
I have another question. It seems that the blxplot plot ignores the negative entries with respect to the selected plotted variable. My hunch is that using "as.numeric(ev)" basically does not capture the reported values for the variables as entered in the csv file??
Sorry to bother you again. Is there a way to select among "factor(tradlib)" instead of plotting them all. Say I want to plot "ev" for all tradlib except "BASE".
Thank you very much once again :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.