Skip to content

How make a boxplot with Y axis in percentage

2 messages · Larissa Schneider Guilhon, Rui Barradas

#
Hello,

I don't see how a boxplot with your dataset can make sense. Maybe a 
barplot like the one below.


dat <-
structure(list(Year = c(2011, 2011, 2011, 2011, 2011, 2011, 2011,
2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011,
2011, 2011, 2011, 2011, 2011, 2011, 2012, 2012, 2012, 2012, 2012,
2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2012, 2012), Q1 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1,
1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1)), .Names = c("Year",
"Q1"), row.names = c(NA, -53L), class = "data.frame")


dat2 <- xtabs(~ Q1 + Year, data = dat)
dat3 <- t(t(dat2)/colSums(dat2))
barplot(dat3, beside = TRUE, legend.text = TRUE)



Also, the best way to give a data example is to use dput():

dput(dat)  # paste the output of this in a post.


That's the structure() above.


Hope this helps,

Rui Barradas


Em 17-03-2013 12:50, Larissa Schneider Guilhon escreveu: