Re: [R] Bar Graph
Dear Rui: thank you very much abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Tue, Sep 11, 2018 at 2:24 PM Rui Barradas wrote: > Hello, > > Use function text() with the return of barplot() as x value and > Number.of.Death as y. > Note that the limits of the y axis are not the automatic ones. > > > > bp <- barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Graph > for > Death Data", ylab="Number of Death", xlab="Cause of Death", ylim = c(0, > 500)) > > text(x = bp, y = Number.of.Death, labels = Number.of.Death, pos = 3) > > > Hope this helps, > > Rui Barradas > > On 11-09-2018 19:02, AbouEl-Makarim Aboueissa wrote: > > Dear All: > > > > > > I do need your help on how to add frequency to bar plot on the top of > each > > bar. > > > > > > here is the R code. > > > > > > *Number.of.Death <- c(432, 217,93, 34, 224)# Number of Death* > > > > *Cause.of.Death <- c("Heart disease", "Cancer", "Stroke", "Accidents", > > "Other") * > > > > *barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Grapg for > > Death Data", ylab="Number of Death", xlab="Cause of Death") * > > > > > > > > Thank you very much for your help in advance. > > > > > > with many thanks > > abou > > __ > > > > > > *AbouEl-Makarim Aboueissa, PhD* > > > > *Professor of Statistics* > > *Graduate Coordinator* > > > > *Department of Mathematics and Statistics* > > *University of Southern Maine* > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Bar Graph
Dear Bert: thank you very much abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Tue, Sep 11, 2018 at 2:47 PM Bert Gunter wrote: > Not quite -- he wanted the frequencies not the counts. So something > like this (using the adj argument to center the frequencies above each > bar: > > bp <-barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar > Graph for Death Data", ylab="Number of Deaths", xlab="Cause of Death", > ylim = c(0,500) ) > > text(bp, y = Number.of.Death + 30, adj = .5, > lab = round(Number.of.Death/sum(Number.of.Death),2)) > > Cheers, > Bert > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > On Tue, Sep 11, 2018 at 11:02 AM AbouEl-Makarim Aboueissa > wrote: > > > > Dear All: > > > > > > I do need your help on how to add frequency to bar plot on the top of > each > > bar. > > > > > > here is the R code. > > > > > > *Number.of.Death <- c(432, 217,93, 34, 224)# Number of Death* > > > > *Cause.of.Death <- c("Heart disease", "Cancer", "Stroke", "Accidents", > > "Other") * > > > > *barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Grapg for > > Death Data", ylab="Number of Death", xlab="Cause of Death") * > > > > > > > > Thank you very much for your help in advance. > > > > > > with many thanks > > abou > > __ > > > > > > *AbouEl-Makarim Aboueissa, PhD* > > > > *Professor of Statistics* > > *Graduate Coordinator* > > > > *Department of Mathematics and Statistics* > > *University of Southern Maine* > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Bar Graph
Not quite -- he wanted the frequencies not the counts. So something like this (using the adj argument to center the frequencies above each bar: bp <-barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Graph for Death Data", ylab="Number of Deaths", xlab="Cause of Death", ylim = c(0,500) ) text(bp, y = Number.of.Death + 30, adj = .5, lab = round(Number.of.Death/sum(Number.of.Death),2)) Cheers, Bert "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Sep 11, 2018 at 11:02 AM AbouEl-Makarim Aboueissa wrote: > > Dear All: > > > I do need your help on how to add frequency to bar plot on the top of each > bar. > > > here is the R code. > > > *Number.of.Death <- c(432, 217,93, 34, 224)# Number of Death* > > *Cause.of.Death <- c("Heart disease", "Cancer", "Stroke", "Accidents", > "Other") * > > *barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Grapg for > Death Data", ylab="Number of Death", xlab="Cause of Death") * > > > > Thank you very much for your help in advance. > > > with many thanks > abou > __ > > > *AbouEl-Makarim Aboueissa, PhD* > > *Professor of Statistics* > *Graduate Coordinator* > > *Department of Mathematics and Statistics* > *University of Southern Maine* > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Bar Graph
Hello, Use function text() with the return of barplot() as x value and Number.of.Death as y. Note that the limits of the y axis are not the automatic ones. bp <- barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Graph for Death Data", ylab="Number of Death", xlab="Cause of Death", ylim = c(0, 500)) text(x = bp, y = Number.of.Death, labels = Number.of.Death, pos = 3) Hope this helps, Rui Barradas On 11-09-2018 19:02, AbouEl-Makarim Aboueissa wrote: Dear All: I do need your help on how to add frequency to bar plot on the top of each bar. here is the R code. *Number.of.Death <- c(432, 217,93, 34, 224)# Number of Death* *Cause.of.Death <- c("Heart disease", "Cancer", "Stroke", "Accidents", "Other") * *barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Grapg for Death Data", ylab="Number of Death", xlab="Cause of Death") * Thank you very much for your help in advance. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Bar Graph
Dear All: I do need your help on how to add frequency to bar plot on the top of each bar. here is the R code. *Number.of.Death <- c(432, 217,93, 34, 224)# Number of Death* *Cause.of.Death <- c("Heart disease", "Cancer", "Stroke", "Accidents", "Other") * *barplot(Number.of.Death, names.arg=Cause.of.Death, main="Bar Grapg for Death Data", ylab="Number of Death", xlab="Cause of Death") * Thank you very much for your help in advance. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Bar Graph
The serialno represents each individual in the data set.The total count of the serialno will represent the whole sample I want to do a graph to compare the total data (serialno) vs each of the remaining five variables yearly. i.e to show the total data (serialno) vs available data for one of the variables in the above case temp axilla. The above code plot count of temp_axilla yearly,how can I include serialno to be part of the plot? I have used library(ggplot2) library(foreign) utils package On Tue, Nov 12, 2013 at 11:53 AM, jwd j...@surewest.net wrote: On Mon, 11 Nov 2013 18:02:19 +0300 Keniajin Wambui kiang...@gmail.com wrote: I am using R 3.0.2 on a 64 bit machine I have a data set from 1989-2002. The data has four variables serialno, date, admission ward, temperature and bcg scar. serialno admin_ward date_admn bcg_scar temp_axilla yr 70162Ward2 11-Oct-89 y 38.9 1989 70163 Ward111-Oct-91 y 37.2 1991 70164 Ward2 11-Oct-92n 37.3 1992 70165 Ward111-Oct-93y38.9 1993 70166 Ward1 11-Oct-94 y 37.7 1994 70167 Ward1 11-Oct-95 y 40 1995 I want to do a bar graph of total data (serialno) vs *(data of one of the variables) to show the available data vs total data over the years i am using gplot(dta, aes(temp_axilla, fill=admin_ward)) + geom_bar() + facet_grid(. ~ yr, scales = free,margins=F) + geom_histogram(binwidth=300) But can include the serialno which shows the data. how can I achieve this You really need to pay better attention somewhere. There are six variables in your example table for instance, not four. You state you want to do something with the serialno variable, but it is not used in your bit of code. Also, given that serialno appears to be unique in your example, a bar graph would be singularly uninformative. You need to provide a better example of the data, and an actual example of the code you are trying to use, including the libraries you've loaded. jwdougherty __ 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. -- Mega Six Solutions Web Designer and Research Consultant Kennedy Mwai 25475211786 __ 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.
Re: [R] Bar Graph
On 11/13/2013 07:20 PM, Keniajin Wambui wrote: The serialno represents each individual in the data set.The total count of the serialno will represent the whole sample I want to do a graph to compare the total data (serialno) vs each of the remaining five variables yearly. i.e to show the total data (serialno) vs available data for one of the variables in the above case temp axilla. The above code plot count of temp_axilla yearly,how can I include serialno to be part of the plot? I have used library(ggplot2) library(foreign) utils package Hi Keniajim, It is not easy to work out what you want. If each serial number is an individual and you want the total number of individuals (dataset is mydata): length(unique(mydata$serialno)) If you want the total number of individuals per year: nind-function(x) return(length(unique(x))) year-as.numeric(format(as.Date(mydata$date_admn,%d-%b-%y),%Y)) by(mydata$serialno,mydata$year,nind) Perhaps this will give you a start. Jim __ 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.
Re: [R] Bar Graph
On Mon, 11 Nov 2013 18:02:19 +0300 Keniajin Wambui kiang...@gmail.com wrote: I am using R 3.0.2 on a 64 bit machine I have a data set from 1989-2002. The data has four variables serialno, date, admission ward, temperature and bcg scar. serialno admin_ward date_admn bcg_scar temp_axilla yr 70162Ward2 11-Oct-89 y 38.9 1989 70163 Ward111-Oct-91 y 37.2 1991 70164 Ward2 11-Oct-92n 37.3 1992 70165 Ward111-Oct-93y38.9 1993 70166 Ward1 11-Oct-94 y 37.7 1994 70167 Ward1 11-Oct-95 y 40 1995 I want to do a bar graph of total data (serialno) vs *(data of one of the variables) to show the available data vs total data over the years i am using gplot(dta, aes(temp_axilla, fill=admin_ward)) + geom_bar() + facet_grid(. ~ yr, scales = free,margins=F) + geom_histogram(binwidth=300) But can include the serialno which shows the data. how can I achieve this You really need to pay better attention somewhere. There are six variables in your example table for instance, not four. You state you want to do something with the serialno variable, but it is not used in your bit of code. Also, given that serialno appears to be unique in your example, a bar graph would be singularly uninformative. You need to provide a better example of the data, and an actual example of the code you are trying to use, including the libraries you've loaded. jwdougherty __ 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.
[R] Bar Graph
I am using R 3.0.2 on a 64 bit machine I have a data set from 1989-2002. The data has four variables serialno, date, admission ward, temperature and bcg scar. serialno admin_ward date_admn bcg_scar temp_axilla yr 70162Ward2 11-Oct-89 y 38.9 1989 70163 Ward111-Oct-91 y 37.2 1991 70164 Ward2 11-Oct-92n 37.3 1992 70165 Ward111-Oct-93y38.9 1993 70166 Ward1 11-Oct-94 y 37.7 1994 70167 Ward1 11-Oct-95 y 40 1995 I want to do a bar graph of total data (serialno) vs *(data of one of the variables) to show the available data vs total data over the years i am using gplot(dta, aes(temp_axilla, fill=admin_ward)) + geom_bar() + facet_grid(. ~ yr, scales = free,margins=F) + geom_histogram(binwidth=300) But can include the serialno which shows the data. how can I achieve this -- Mega Six Solutions Web Designer and Research Consultant Kennedy Mwai __ 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.
Re: [R] Bar graph with 2 Y axis
On 03/16/2012 09:24 AM, KAYIS Seyit Ali wrote: Dear R users, I need to draw a barplot with 2 Y axis. I have 3 days each of wich having 2 groups (and error bar for each of them). The height of the 3rd day is too tall compared to others. That's why I have to use a second Y axis for that. I am using barplot2 function of gplots library (to be able to add error bars as well). Data and codes currently I am using is below. ... Any help regarding adding second Y axis is deeply apprecited. Hi Seyit, It is fairly easy to get the bars like this: library(plotrix) barpos-barp(means,ylim=range(means+SEM)+c(0,4),col=2:3) dispersion(barpos$x,barpos$y,CIU,CIL,interval=FALSE) or even more simply: dispersion(barpos$x,barpos$y,SEM) I am not sure that you need an extra y axis here. Jim __ 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.
[R] Bar graph with 2 Y axis
Dear R users, I need to draw a barplot with 2 Y axis. I have 3 days each of wich having 2 groups (and error bar for each of them). The height of the 3rd day is too tall compared to others. That's why I have to use a second Y axis for that. I am using barplot2 function of gplots library (to be able to add error bars as well). Data and codes currently I am using is below. == means-matrix(c(2.3, 2.0, 0.0, 3.0, 2.5, 40), nrow=2, byrow=TRUE) SEM-matrix(c(0.3, 0.2, 0.0, 0.4, 0.3, 10), nrow=2, byrow=TRUE) CIL-means-SEM CIU-means+SEM rname-c(Gr1, Gr2) cname-c(day1, day2, day3) rownames(means)-rname rownames(CIL)-rname rownames(CIU)-rname colnames(means)-cname colnames(CIL)-cname colnames(CIU)-cname library(gplots) barplot2(means, beside = TRUE, angle = c(30, 45), density = c(-1, 10), col = c(white, black), #legend = rname[1], ylim = c(0, 5), cex.axis=2, ylab=Frequency), cex.lab=2, ci.lwd=2, grid.lwd =2, cex.names = 1.7, plot.ci = TRUE, ci.l = CIL, ci.u = CIU, plot.grid = TRUE) legend(topleft, legend=rname, fill = c(white, black), border=black, angle = c(30, 45), density = c(-1, 10), col = c(white, black), bty = o, bg = par(bg), box.lwd = par(lwd), box.lty = par(lty), box.col = par(fg), pt.bg = NA, cex = 2, pt.cex = cex, pt.lwd = lwd, xjust = 0, yjust = 1, x.intersp = 1, y.intersp = 1, adj = c(0, 0.5), text.width = NULL, text.col = par(col), plot = TRUE, ncol = 1, horiz = FALSE, title = NULL, inset = 0, title.col = text.col, title.adj = 0.5, seg.len = 2) box() Any help regarding adding second Y axis Dr. Seyit Ali KAYIS Selcuk University, Faculty of Agriculture Kampus/Konya, Turkey Tel: +90 332 223 2830 Mobile: +90 535 587 1139 Greetings from Konya, Turkey http://www.ziraat.selcuk.edu.tr/skayis/ Any help regarding adding second Y axis is deeply apprecited. Kind Regards Seyit Ali [[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.