Hi Tom,

How nice of you to take a look, i really want to understand this for once
and for all. I have attached the SPSS data file and the picture i got. the
code i used i have put below, can you see what i need to get the legend
above the bars in the picture, (maybe my y-axis needs to be longer as well
in order to get this) and the background should be without (grid)lines or
any color.

this is the code i used

getwd()

setwd("/Users/benjamintelkamp/Desktop/WISI 2013-2014/Graphing in R")

library(ggplot2)

library(foreign)

install.packages("Hmisc")

library(Hmisc)

install.packages("MASS")

library(MASS)

DATA1 <- "Data CB.sav"

DATA1 <- read.spss(file=DATA1, use.value.labels=TRUE, to.data.frame=TRUE)

head(DATA1)

Bar_Mani_Excl <- ggplot(DATA1, aes(PT_manipulation, Perc_Worpen, fill =
Exclusion))

Bar_Mani_Excl + stat_summary(fun.y = mean, geom = "bar", position =
"dodge") + stat_summary(fun.data = mean_cl_normal, geom = "errorbar",
position = position_dodge(width=0.90), width = 0.2) + labs (x = "PT
Manipulatie", y = "Percentage Balworpen")


you would make me so happy!


thank you,


Benjamin Telkamp




On 4 January 2014 16:34, Dr. Thomas W. MacFarland [via R] <
ml-node+s789695n4683088...@n4.nabble.com> wrote:

> Hi Benjamin:
>
> If the problem is legend location, then look at the legend help page and
> note the beginning statement:
>
>      legend {graphics} R Documentation
>
>      This function can be used to add legends to plots. Note that a call
> to the function locator(1) can be used in place of the x and y arguments.
>
> Sample code, not for a barplot but still relevant, follows.
>
> And yes, for your specific problem the barplot() function may be all that
> you need, and then fine tune legend composition and placement.
>
> Best wishes.
>
> Tom
>
> savelwd      <- par(lwd=4)         # Heavy line
> par(ask=TRUE)
> sm::sm.density.compare(GenRegM1M2.df$M1,
>   GenRegM1M2.df$Gender.recode,
>   xlab=list("M1", cex=1.15, font=2),
>   ylab=list("Density", cex=1.15, font=2),
>   xlim=c(0,120), ylim=c(0,0.05))    # Adjust as needed
>   title(main="Density Plot of M1 by Gender")
> colorfill <- c(2:(2+length(levels(
>   GenRegM1M2.df$Gender.recode))))
> legend(locator(1), levels(
>   GenRegM1M2.df$Gender.recode),
>   fill=colorfill)
>   # Remember to click on an open location to paste the
>   # legend into the figure.
> par(savelwd)
>   # Note how the line width is accommodated and then
>   # set back to the original value.
>
>
>
> Date: Sat, 04 Jan 2014 20:44:35 +1100
> From: Jim Lemon <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=4683088&i=0>>
>
> To: "Benjamin Telkamp [via R]"
>         <[hidden email]<http://user/SendEmail.jtp?type=node&node=4683088&i=1>>
>
> Cc: r-help-2 <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=4683088&i=2>>
>
> Subject: Re: [R] APA two-way bar-chart
> Message-ID: <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=4683088&i=3>>
>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 01/04/2014 03:08 AM, Benjamin Telkamp [via R] wrote:
>
> > Dear R-users,
> >
> > I'm struggling with APA formatted two way BAR-charts according to
> apa-style
> > i should have the legend in the background of my plot (so above the bars
> and
> > not beside the picture/plot itself) and the background should be
> completely
> > white without gridlines or what so ever. Could any one give me a hint or
> > solution? See Below for my commands
> >
> > thank you so much,
> >
> > Benjamin Telkamp (Email: [hidden 
> > email]<http://user/SendEmail.jtp?type=node&node=4683088&i=4>,
> The Netherlands)
> >
> > these are the commands used so far which just didn't give me what i
> wanted
> >
> > library(ggplot2)
> > library(foreign)
> > install.packages("Hmisc")
> > DATA1<- read.spss(file=DATA1, use.value.labels=TRUE, to.data.frame=TRUE)
> > Bar_PD<- ggplot(DATA1, aes(Age_group, IRI_PD ))
> > Bar_PD + stat_summary(fun.y = mean, geom = "bar", fill = "Purple") +
> > stat_summary(fun.data = mean_cl_normal, geom = "errorbar", width = 0.2)
> +
> > labs (x = "Leeftijdsgroep", y = "IRI PD") + theme(plot.background =
> > element_rect(colour= "White"))
> >
> Hi Benjamin,
> I'm not sure what you mean by a two way bar chart. If it is a grouped
> barplot in which the members of each group are defined by the levels of
> one discrete variable and the groups are defined by another discrete
> variable, the basic "barplot" function with an added legend should do
> what you want. Can you give an example such as an image on the internet
> that shows what you want?
>
> Jim
> ----------
> Thomas W. MacFarland, Ed.D.
> Senior Research Associate; Institutional Effectiveness and Associate
> Professor
> Nova Southeastern University
> Voice 954-262-5395 [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=4683088&i=5>
>
> ______________________________________________
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4683088&i=6>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.
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
> http://r.789695.n4.nabble.com/APA-two-way-bar-chart-tp4683046p4683088.html
>  To unsubscribe from APA two-way bar-chart, click 
> here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4683046&code=aW56aWNodGVsaWprQGdtYWlsLmNvbXw0NjgzMDQ2fC0xNjc3ODIzODA1>
> .
> NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Wiskunde & Statistiek Inzichtelijk (WISI)

www.wisi.nl
b.telk...@wisi.nl
inzichtel...@gmail.com

mobile 0644835211


B.S.D. Telkamp

Herenstraat 1A
2313 AD Leiden

rekeningnummer (Triodos Bank): 39.01.30.605 t.n.v. WISI


Data CB.sav (22K) 
<http://r.789695.n4.nabble.com/attachment/4683090/0/Data%20CB.sav>
two-way barchart .pdf (104K) 
<http://r.789695.n4.nabble.com/attachment/4683090/1/two-way%20barchart%20.pdf>




--
View this message in context: 
http://r.789695.n4.nabble.com/APA-two-way-bar-chart-tp4683046p4683090.html
Sent from the R help mailing list archive at Nabble.com.
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to