[R] How make a boxplot with Y axis in percentage

Rui Barradas ruipbarradas at sapo.pt
Sun Mar 17 22:22:58 CET 2013


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:
> I have to make a boxplot with Years 2011 and 2012 on the x axis, and
> percentage of full time students (=1) and part time students (=2) on the y
> axis.
> I would really appreciate if someone can help me to build a proper code.
> Thanks
> Larissa
>
> Data as follow:
>
>
> Year
>
> Q1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 2
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 2
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 1
>
> 2011
>
> 2
>
> 2011
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 2
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 2
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 2
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 2012
>
> 1
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list