Re: [R] Barplot for data frame

2023-11-29 Thread Ben Tupper
Another great resource is RSeek.org https://rseek.org/?q=barplot On Wed, Nov 29, 2023 at 4:26 AM Ivan Krylov wrote: > В Wed, 29 Nov 2023 00:29:49 + > Livio Beqiri пишет: > > > how can i create a vertical barplot that displays brands in x-axis > > and Revenue in Y-axis > > What have you tri

Re: [R] Barplot for data frame

2023-11-29 Thread Ivan Krylov
В Wed, 29 Nov 2023 00:29:49 + Livio Beqiri пишет: > how can i create a vertical barplot that displays brands in x-axis > and Revenue in Y-axis What have you tried? If you're not currently studying R with an instructor (who should be contacted with basic questions like this instead; see the p

Re: [R] Barplot for data frame

2023-11-29 Thread Dr Eberhard Lisse
Look like homework to me :-)-O el On 2023-11-29 02:29 , Livio Beqiri wrote: I have a dataframe df <- df <- data.frame (Revenue = c("100", "300", "500"), Brand = c("Apple", "HP", "Lenovo") ) how can i create a vertical barplot that displays brands in x-ax

Re: [R] barplot that displays sums of values of 2 y colums grouped by different variables

2018-01-16 Thread kenneth dyson
Thanks everyone. Got it to work like this, if anyone is interested: import the data with readr, taking in only the columns that have numeric values ("n" and "y") and the column with the groups ("city"). aggregate the data by the group ("city") so that each variable has a sum: |sum_data <-aggre

Re: [R] barplot that displays sums of values of 2 y colums grouped by different variables

2018-01-15 Thread Jeff Newmiller
It is not generally advisable to get too fancy with stat functions in ggplot... things can easily get more complicated than ggplot is ready to handle when it comes to calculations. It is better to create data that corresponds directly to the graphical representations you are mapping them to.

Re: [R] barplot that displays sums of values of 2 y colums grouped by different variables

2018-01-15 Thread Jim Lemon
Hi Kenneth, I don't know about ggplot, but perhaps this will help: kddf<-read.table(text="city n y mon 100 200 tor 209 300 edm 98 87 mon 20 76 tor 50 96 edm 62 27", header=TRUE,stringsAsFactors=FALSE) library(plotrix) barpos<-barp(t(kddf[,2:3]),names.arg=kddf[,1],xlab="City",ylab="Sum", main="Sum

Re: [R] barplot that displays sums of values of 2 y colums grouped by different variables

2018-01-15 Thread Eric Berger
https://stackoverflow.com/questions/25070547/ggplot-side-by-side-geom-bar On Mon, Jan 15, 2018 at 9:39 PM, Kenneth Dyson wrote: > Hi Eric, > > Thanks for the detailed response. > This is not exactly what I want to do but is close. > I want 2 bars for each city, 1 with the sum for "yes" , the oth

Re: [R] barplot that displays sums of values of 2 y colums grouped by different variables

2018-01-15 Thread Eric Berger
'position="dodge"' has no effect in the plot because the x-axis is a factor variable. The bars do not need to be moved to avoid each other. The 'aes(fill=y)' is specifying that you want the color gradient to capture the sums in the 'y' variable. You might be better off to use 'no' and 'yes' rather

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Jim Lemon
Hi Adrian, Perhaps what you want is this: ajdat<-structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L, 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN", "CN"), c("DC5", "DC8", "DC14", "DC18", "DC19", "DC20", "DC23" ))) library(plotrix) twoord.plot(0.8:6.8,ajdat[2,],1.2:7.2,

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
gt;> David L Carlson >> Department of Anthropology >> Texas A&M University >> College Station, TX 77840-4352 >> >> >> >> -Original Message- >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Adams, Jean >> Sent: Wedne

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
David L Carlson > Department of Anthropology > Texas A&M University > College Station, TX 77840-4352 > > > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Adams, Jean > Sent: Wednesday, October 12, 2016 12:44 PM > To: Adrian Johnso

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread David L Carlson
p-boun...@r-project.org] On Behalf Of Adams, Jean Sent: Wednesday, October 12, 2016 12:44 PM To: Adrian Johnson Cc: r-help Subject: Re: [R] barplot beside=TRUE - values differ on scales Adrian, Very interesting. What do you think of using colors to indicate the five possible loss/gain levels? For example:

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adams, Jean
Adrian, Very interesting. What do you think of using colors to indicate the five possible loss/gain levels? For example: a <- structure(c(112L, 0L, 579L, 1L, 131L, 1L, 2234L, 2L, 2892L, 1L, 528L, 0L, 582L, 2L), .Dim = c(2L, 7L), .Dimnames = list(c("GN", "CN"), c("DC5", "DC8", "DC14", "DC18",

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Duncan Murdoch
On 12/10/2016 12:59 PM, Adrian Johnson wrote: Thanks Duncan. I am sorry I cannot scale second row (d[2,]). I was looking for a way to plot d[2,] values next to d[1,] with a right side axis=4 on right side. -2,-1,0,1,2 That doesn't really make graphical sense, but you can use any transformati

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
Thanks Duncan. I am sorry I cannot scale second row (d[2,]). I was looking for a way to plot d[2,] values next to d[1,] with a right side axis=4 on right side. -2,-1,0,1,2 thanks Adrian On Wed, Oct 12, 2016 at 12:42 PM, Duncan Murdoch wrote: > On 12/10/2016 12:20 PM, Adrian Johnson wrote: >> >>

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adrian Johnson
Hi Adams, The story I am trying to show visually relationship between GN and CN for every column. Each column represents a patient. In each patient, a particular chromosome region (CN) is either lost (-2 or -1) or gained (1 or 2). Typically if loss (one copy loss - as humans have pair of chromosome

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Duncan Murdoch
On 12/10/2016 12:20 PM, Adrian Johnson wrote: Dear group, I have been struggling to barplot two different measurements from one subject. These two measures differ in range. I want to plot row 1 axis on left side and row 2 values on right side. For a given column I want to plot GN and CN next to

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread Adams, Jean
Adrian, What story are you trying to tell? Or what question are you trying to answer by visualizing these data? How is a bar plot of these numbers going to help? I'm just wondering if perhaps a different visualization might make more sense, for example, a scatter plot of GN vs. CN. m <- struct

Re: [R] barplot beside=TRUE - values differ on scales

2016-10-12 Thread S Ellison
I have suspect that the most common answer to this will be 'don't', for all the reasons statisticians don't like mixing vertical scales on the same plot. See http://www.perceptualedge.com/articles/visual_business_intelligence/dual-scaled_axes.pdf for one article on that topic. But if you must,

Re: [R] barplot colour problem

2016-07-18 Thread Abdoulaye Sarr
Thank you Marc, The typo was causing the problem, solved now. Regards, Fipou On Mon, Jul 18, 2016 at 8:38 PM, Marc Schwartz wrote: > > > On Jul 18, 2016, at 1:06 PM, Abdoulaye Sarr > wrote: > > > > I am doing a basic bar plot which works but the color of bars positive > > (green) and negative

Re: [R] barplot colour problem

2016-07-18 Thread Marc Schwartz
> On Jul 18, 2016, at 1:06 PM, Abdoulaye Sarr wrote: > > I am doing a basic bar plot which works but the color of bars positive > (green) and negative (brown) don’t show up from the below command: > > barplot(z, ylim=c(-2,2), col=ifelse(x>0,"brown","green »)) > > any help? or other methods? >

Re: [R] Barplot - Beginners Question

2015-10-04 Thread Boris Steipe
On Oct 4, 2015, at 7:39 PM, Duncan Murdoch wrote: > You'll get what you want if you use as.matrix(datentabelle)[,1] > instead of datentabelle[,1]. This happens to work in this particular case, but fails if the data frame contains text columns. Example: datentabelle <- cbind(datentabelle, tex

Re: [R] Barplot - Beginners Question

2015-10-04 Thread Duncan Murdoch
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 04/10/2015 3:31 PM, Jutta Wrage wrote: > Hi! > > According to this I tried to create a barplot: > > https://de.wikibooks.org/wiki/GNU_R:_barplot > > Input Data (Tab delimeted) > > Range Anzahl Prozent 36-40 12 1.92 41-45 21 3.

Re: [R] barplot -issues with axis and labels not appearing

2015-07-22 Thread Jim Lemon
Hi Pierre, I get a reasonable plot using the following code: par(mar=c(6,4,4,2)) barpos<-barplot(unlist(GEP.data2), main="Global Portfolio Weights", col.main="gray", col=blues9, cex.axis=1, ylim=c(-1,1), las=2, cex.lab=1, cex=0.8) axis(1,at=barpos,labels=rep("",8)) For one thing, you don't ne

Re: [R] Barplot

2015-02-24 Thread PIKAL Petr
Hi Homework? We do not solve your homeworks here. barplot(temp$revenue) and play with col and names.arg together with ?interaction of Year and Gender Or use ggplot2 Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Partha > Sinha > Sen

Re: [R] barplot: segment-wise shading

2014-01-17 Thread Marc Schwartz
On Jan 16, 2014, at 9:09 PM, Martin Weiser wrote: > Jim Lemon píše v Pá 17. 01. 2014 v 13:21 +1100: >> On 01/17/2014 10:59 AM, Marc Schwartz wrote: >>> >>> ... >>> Arggh. >>> >>> No, this is my error for not actually looking at the plot and presuming >>> that it would work. >>> >>> Turns out

Re: [R] barplot: segment-wise shading

2014-01-16 Thread Martin Weiser
Jim Lemon píše v Pá 17. 01. 2014 v 13:21 +1100: > On 01/17/2014 10:59 AM, Marc Schwartz wrote: > > > > ... > > Arggh. > > > > No, this is my error for not actually looking at the plot and presuming > > that it would work. > > > > Turns out that it does work for a non-stacked barplot: > > > >ba

Re: [R] barplot: segment-wise shading

2014-01-16 Thread Jim Lemon
On 01/17/2014 10:59 AM, Marc Schwartz wrote: ... Arggh. No, this is my error for not actually looking at the plot and presuming that it would work. Turns out that it does work for a non-stacked barplot: barplot(VADeaths, angle = 1:20 * 10, density = 10, beside = TRUE) However, internally

Re: [R] barplot: segment-wise shading

2014-01-16 Thread Marc Schwartz
On Jan 16, 2014, at 5:03 PM, Martin Weiser wrote: > Marc Schwartz píše v Čt 16. 01. 2014 v 16:46 -0600: >> On Jan 16, 2014, at 12:45 PM, Martin Weiser wrote: >> >>> Dear listers, >>> >>> I would like to make stacked barplot, and to be able to define shading >>> (density or angle) segment-wise

Re: [R] barplot: segment-wise shading

2014-01-16 Thread Martin Weiser
Marc Schwartz píše v Čt 16. 01. 2014 v 16:46 -0600: > On Jan 16, 2014, at 12:45 PM, Martin Weiser wrote: > > > Dear listers, > > > > I would like to make stacked barplot, and to be able to define shading > > (density or angle) segment-wise, i.e. NOT like here: > > # Bar shading example > > b

Re: [R] barplot: segment-wise shading

2014-01-16 Thread Marc Schwartz
On Jan 16, 2014, at 12:45 PM, Martin Weiser wrote: > Dear listers, > > I would like to make stacked barplot, and to be able to define shading > (density or angle) segment-wise, i.e. NOT like here: > # Bar shading example > barplot(VADeaths, angle = 15+10*1:5, density = 20, col = "black", >

Re: [R] Barplot not showing all labels

2014-01-15 Thread Jeff Johnson
is, what you see is not > what you think you have. You only have one variable in the data.frame and > that is the country names. > > For some reason the numbers are being considered as row names not as a > variable. Do a str(filename) to see what is happening. You do need to >

Re: [R] Barplot not showing all labels

2014-01-15 Thread Jeff Johnson
Sorry guys, I'm running into an issue. I have a data frame. Here is the dput output having run: dput(head((non_us),25), file = "C:/Users/jeffjohn/Desktop/non_us_sam.csv", control = c("keepNA", "keepInteger","showAttributes")) structure(list(COUNTRY = structure(c(4L, 25L, 35L, 12L, 4L, 5L, 14L, 14L

Re: [R] Barplot not showing all labels

2014-01-15 Thread John Kane
ld you aggregate before graphing? John Kane Kingston ON Canada -Original Message- From: mrjeffto...@gmail.com Sent: Wed, 15 Jan 2014 09:20:11 -0800 To: jrkrid...@inbox.com Subject: Re: [R] Barplot not showing all labels Sorry guys, I'm running into an issue. I have a data frame. H

Re: [R] Barplot not showing all labels

2014-01-14 Thread Jeff Johnson
Thanks John (and everyone else as well). John's example got it very close. I can tweak from here. Thanks! On Tue, Jan 14, 2014 at 1:22 PM, John Kane wrote: > I am not sure that I got the data correctly--it is much better to supply > sample data using dput(). See ?dput for more information but I

Re: [R] Barplot not showing all labels

2014-01-14 Thread John Kane
I am not sure that I got the data correctly--it is much better to supply sample data using dput(). See ?dput for more information but I think something like this will work dat1 / <- structure(list(cty = structure(1:70, .Label = c("AE", "AN", "AR", "AT", "AU", "BB", "BD", "BE", "BH", "BM", "BN"

Re: [R] Barplot not showing all labels

2014-01-13 Thread William Dunlap
n...@r-project.org] On > Behalf > Of Jim Lemon > Sent: Monday, January 13, 2014 1:43 PM > To: Jeff Johnson > Cc: r-help@r-project.org > Subject: Re: [R] Barplot not showing all labels > > On 01/14/2014 06:15 AM, Jeff Johnson wrote: > > I have a table that consist

Re: [R] Barplot not showing all labels

2014-01-13 Thread Jim Lemon
On 01/14/2014 06:15 AM, Jeff Johnson wrote: I have a table that consists of the following country codes and frequencies: AE AN AR AT AU BB BD BE BH BM BN BO BR BS CA CH CM CN CO CR CY DE DK DO EC ES 0 3 0 2 1 31 4 1 1 1 45 1 1 4 5 86 3 1 8 1 2 1 8 2 1 2 4 FI FR GB GR

Re: [R] barplot - easy for experienced, difficult for me

2013-10-01 Thread Jim Lemon
On 10/01/2013 07:32 PM, happyR wrote: hey lobachevsky - thanks! but: Error in barplot.default (matrix, col = c("yellow","purple"), beside = TRUE) : 'height' must be a vector or a matrix what to do? :) First, one must always avoid confusing the general case with a specific instance. If you

Re: [R] barplot - easy for experienced, difficult for me

2013-10-01 Thread happyR
hey lobachevsky - thanks! but: Error in barplot.default (matrix, col = c("yellow", "purple"), beside = TRUE) : 'height' must be a vector or a matrix what to do? :) Gesendet: Dienstag, 01. Oktober 2013 um 10:42 Uhr Von: "Jim Lemon [via R]"

Re: [R] barplot - easy for experienced, difficult for me

2013-10-01 Thread John Kane
There is a slight problem with that second link. It is the same as the first. It is easier to sent the data (or a decent sample of it) in the email by using dput. Type ?dput for more information. Essentially you just do dput(myfile) copy it and paste it into the email. This allow the reader t

Re: [R] barplot - easy for experienced, difficult for me

2013-10-01 Thread Jim Lemon
On 10/01/2013 05:53 PM, happyR wrote: ... Do you think it might have sth to do with how my dataset is built up? Yes, happyR, it is definitely your dataset. I think this one is far superior: spineless<-matrix(c(6,3,9,5,4,6,7,1,3,8,7,6,10,4,3,7,6,11), nrow=2) slnames<-c("Bug","Slug","Wasp","Ti

Re: [R] barplot - easy for experienced, difficult for me

2013-10-01 Thread happyR
Hi Jean,   I tried to follow the introductions on statmethods... Didn't really work.   Do you think it might have sth to do with how my dataset is built up?   Thanks for your help!   Tobias       Gesendet: Montag, 30. September 2013 um 23:27 Uhr Von: "Adams, Jean [via R]" <

Re: [R] barplot - easy for experienced, difficult for me

2013-09-30 Thread Adams, Jean
Look at the example for grouped bar plots here, http://www.statmethods.net/graphs/bar.html Jean On Mon, Sep 30, 2013 at 8:05 AM, happyR wrote: > hey guys, > > I wanna make a simple barplot, looking like this excel graph: >

Re: [R] barplot to the right side

2013-09-30 Thread Jim Lemon
On 09/30/2013 07:47 PM, Juan Andres Hernandez wrote: Hi, does anybody know how to get a barplot with the x axis starting in the right side and the y axis in the right side too? An example: dat=c(2,4,0,6,5) names(dat)=paste('dpt.',1:5,sep='') barplot(dat, horiz=T) box() I need this barplot in mi

Re: [R] barplot: add an image in each bar

2013-08-14 Thread Jim Lemon
On 08/15/2013 01:16 AM, Igor Ribeiro wrote: Dear all, I need to insert an small icon in each bar of a barplot, in a specific location (depending on bar's value). For example: the first bar has X value of 5. I need to insert an icon at X value 3. The second bar has X value of 8. I need to insert a

Re: [R] barplot colors

2013-03-26 Thread Francois De Ryckel
Hi Rui, Thanks for trying. I know about the beside. The reason I want them stack with various colors is that the 4 stacks represent the number of students on each quartiles on a test. Have a terrific Tuesday! François On 26 Mar 2013, at 21:45, Rui Barradas wrote: > Hello, > > I forgot to

Re: [R] barplot colors

2013-03-26 Thread Francois De Ryckel
Hi David, Thanks a lot for your advice and helping me tricking barplot. It totally work. Have a great evening! François On 26 Mar 2013, at 21:43, David L Carlson wrote: > You will have to trick barplot into thinking you have four groups: > >> wmod <- cbind(c(w[,1], 0, 0), c(0, 0, w[,2])) >> b

Re: [R] barplot colors

2013-03-26 Thread Rui Barradas
Hello, I forgot to add that if you use argument beside = TRUE, you can have as many colors as there are bars, but this is not the kind of graph you want. (This behavior makes a lot of sense if you look at the underlying code for barplot.) Rui Barradas Em 26-03-2013 19:39, Rui Barradas escre

Re: [R] barplot colors

2013-03-26 Thread David L Carlson
You will have to trick barplot into thinking you have four groups: > wmod <- cbind(c(w[,1], 0, 0), c(0, 0, w[,2])) > barplot(wmod, main="2012", col=c("red", "green", "blue", "pink")) -- David L Carlson Associate Professor of Anthropology Texas A&M Unive

Re: [R] barplot colors

2013-03-26 Thread Rui Barradas
Hello, According to the code in file src/R/graphics/barplot.R, barplot() will draw column by column, and threfore use as many colors as rows in the matrix. Those colors will be reused for all bars. So I'm not seeing an easy way of doing what you want using base graphics. Not without changing

Re: [R] Barplot with lines

2012-11-25 Thread Ripples
Hi Jim, I did the same and it worked. Thanks a lot! SK On Fri, Nov 23, 2012 at 6:11 PM, Jim Lemon wrote: > On 11/24/2012 02:21 AM, skanap wrote: > >> >> Hi Jim, >> >> Thank you for the reply. But, when I use Barpos I get this error. >> >> plot(mydata$score,barpos) >> Error in xy.coords(x, y, x

Re: [R] Barplot with lines

2012-11-23 Thread Jim Lemon
On 11/24/2012 02:21 AM, skanap wrote: Hi Jim, Thank you for the reply. But, when I use Barpos I get this error. plot(mydata$score,barpos) Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ I need all the points in x-axis that are in 'days' column. If I'm selecting o

Re: [R] Barplot with lines

2012-11-23 Thread skanap
Hi Jim, Thank you for the reply. But, when I use Barpos I get this error. plot(mydata$score,barpos) Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ I need all the points in x-axis that are in 'days' column. If I'm selecting only points in val1 and val2 I'm missing

Re: [R] Barplot with lines

2012-11-23 Thread Greg Snow
Look at the updateusr function in the TeachingDemos package. One of the examples shows adding lines to a barplot. On Fri, Nov 23, 2012 at 12:33 AM, Ripples <9ripp...@gmail.com> wrote: > Hi, > > I'm trying to plot stacked barplot with lines on it. Here is the data. > > emp days val1 val2 score

Re: [R] Barplot with lines

2012-11-23 Thread Jim Lemon
On 11/23/2012 06:33 PM, Ripples wrote: Hi, I'm trying to plot stacked barplot with lines on it. Here is the data. emp days val1 val2 score 1 21 1 0 1200 2 35 1 1 na 3 42 na na 3000 4 53 2 1 2100 5 64 1 0 na 6 73 na na 1400 My X-axis is days. I'm looking to plot val1,val2 as stacked bars and s

Re: [R] barplot

2012-10-24 Thread Jim Lemon
On 10/24/2012 03:21 AM, Thiho Jules wrote: Hi, I want to make a barplot with the following datasets: I have a file as following: name chr position A1 A2 pop1 pop1 pop2 pop2 I have calculated a measure using all the values in columns "pops", the values are saved in a vector. Now I want to ma

Re: [R] barplot

2012-10-23 Thread arun
Hi, May be this example helps you. dat1<-data.frame(position= 1:5,pop1=c(3,5,15,25,28),pop2=c(5,8,12,22,35),pop3=c(2,10,17,20,31)) dat2<-melt(dat1,id.vars="position") library(lattice) barchart(value~factor(position),data=dat2) A.K. - Original Message - From: Thiho Jules To: r-help@r

Re: [R] barplot with some 0 frequencies

2012-10-05 Thread Guillaume2883
Thank for all your answer ! Here is another way I discoverd this morning : barplot(table(factor(variable, levels = 1:4)),names=c(1,2,3,4)) -- View this message in context: http://r.789695.n4.nabble.com/barplot-with-some-0-frequencies-tp4645102p4645208.html Sent from the R help mailing list arc

Re: [R] barplot with some 0 frequencies

2012-10-05 Thread Greg Snow
Others have shown barchart commands that include 0's. My guess (which could be wrong, feel free to ignore this e-mail if so) is that your problem is due to the way you are creating/summarizing the data before the plotting command is used. R needs some way to know about what bars you want, even if

Re: [R] barplot with some 0 frequencies

2012-10-05 Thread David Winsemius
On Oct 4, 2012, at 9:05 PM, David Winsemius wrote: > > On Oct 4, 2012, at 4:49 PM, Guillaume2883 wrote: > >> Hi all, >> >> I am back with a new question ! >> I recorded the occurence of 4 differents event on 20 places for a given time >> period. >> Now, I want to do some barplot of the frequen

Re: [R] barplot with some 0 frequencies

2012-10-04 Thread Richard M. Heiberger
barchart(-3:3 ~ letters[1:7], origin=0) On Fri, Oct 5, 2012 at 12:05 AM, David Winsemius wrote: > > On Oct 4, 2012, at 4:49 PM, Guillaume2883 wrote: > > > Hi all, > > > > I am back with a new question ! > > I recorded the occurence of 4 differents event on 20 places for a given > time > > period

Re: [R] barplot with some 0 frequencies

2012-10-04 Thread David Winsemius
On Oct 4, 2012, at 4:49 PM, Guillaume2883 wrote: > Hi all, > > I am back with a new question ! > I recorded the occurence of 4 differents event on 20 places for a given time > period. > Now, I want to do some barplot of the frequency of theses events for each > place, so it should be easy. My pr

Re: [R] Barplot with Secondary axis

2012-08-22 Thread vikrant
Thanks Rui and Greg for providing me the solution , it Works. -- View this message in context: http://r.789695.n4.nabble.com/Barplot-with-Secondary-axis-tp4640980p4641081.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-pr

Re: [R] Barplot with Secondary axis

2012-08-22 Thread Greg Snow
Using par(new=TRUE) will often cause more problems than it helps. A better approach would be to use the twoord.plot function from the plotrix package or to use the updateusr function from the TeachingDemos package along with the lines function to add the lines afterwards. On Wed, Aug 22, 2012 at

Re: [R] Barplot with Secondary axis

2012-08-22 Thread Rui Barradas
Hello, You were almost there. x = c("a","b","c","d") y= cbind(c(50,40,30,20),c(40,30,20,10)) y2 = c(0.80,0.65,0.75,0.50) # bp <- barplot(t(y), beside = TRUE) xlim <- c(floor(min(bp)), ceiling(max(bp))) # par(new=T) plot(colMeans(bp), y2, type="o", col="black", lwd=3, lty=1, xaxt="n", yaxt="n

Re: [R] barplot question

2012-07-31 Thread Rui Barradas
Hello, Ok, final retouches. 1. Divide the par() call: oldpar <- par(mar=c(9, 4.1, 4.1, 2.1)) oldfont <- par(font=3) Then, just before legend() par(oldfont) # back to normal font 2. Modify the text() call to text(as.vector(bp), y = -6.5, cex=0.7, pos = 2, offset = -0.25, ...etc

Re: [R] barplot question

2012-07-30 Thread Rui Barradas
Hello, Try the following. plants_herbs_input_top10 <- structure(list(total = c(28L, 17L, 11L, 6L, 6L, 5L, 4L, 3L, 3L, 2L), young = c(29L, 22L, 15L, 8L, 5L, 3L, 2L, 2L, 2L, 2L), old = c(36L, 11L, 11L, 8L, 6L, 5L, 4L, 3L, 2L, 2L)), .Names = c("total", "young", "old"), class = "data.frame", row.

Re: [R] barplot problem

2012-05-27 Thread jack hietpas
Richard- thank you very very much, this is exactly what I needed. I have not previously used lattice graphics, I will have to experiment more with this package. Also thanks to everyone for your input. -jh On Sun, May 27, 2012 at 1:04 PM, Richard M. Heiberger wrote: > I would use barchart in la

Re: [R] barplot problem

2012-05-27 Thread Richard M. Heiberger
I would use barchart in lattice. To get control of spacing you need to use the panel.barchart with the xyplot function. I show two options below. The first labels the distance scale with the default values seq(0,300,50), The second labels the bars with their distance value. tmp <- data.frame(y

Re: [R] barplot problem

2012-05-27 Thread Uwe Ligges
On 27.05.2012 17:46, jack hietpas wrote: Hi Jim- Thanks for your help. I am not sure how to execute your instructions... I used the space argument to to equally space the bars (barplot(data, space=c(1,1,1,1,1,1)). How do I get the "x positions in the return values". Take care, xp <- barpl

Re: [R] barplot problem

2012-05-27 Thread jack hietpas
Hi Jim- Thanks for your help. I am not sure how to execute your instructions... I used the space argument to to equally space the bars (barplot(data, space=c(1,1,1,1,1,1)). How do I get the "x positions in the return values". Take care, -jh On Sun, May 27, 2012 at 3:42 AM, Jim Lemon wrote:

Re: [R] barplot problem

2012-05-27 Thread Jim Lemon
On 05/27/2012 01:26 PM, jack hietpas wrote: Hello- I am having trouble making a barplot... The y-values are: data=c(-0.0002129061,0.00,-0.0002699561,0.0163883061,0.04). The x-values are distance=c(0, 71, 172, 206, 292). The desired x-range is 0 and ~300+ (kilometers), range=seq(

Re: [R] barplot problem

2012-05-26 Thread R. Michael Weylandt
It sounds like you want something of the form plot(distance, data, type = "h") But the lines might be too thin: try adding lwd = NUM to increase the thickness. Hope this helps, Michael On Sat, May 26, 2012 at 11:26 PM, jack hietpas wrote: > Hello- I am having trouble making a barplot... > > Th

Re: [R] barplot

2012-05-23 Thread Rui Barradas
Hello, Would the following do it? # make the dates vector x <- seq(as.Date("2011-03-15"), as.Date("2011-09-09"), by="day") # this is the important part labs <- seq(min(x), max(x), by="month") # "month", not 30 labs <- format(labs, "%b") labs.pos <- round(seq(1, length(x), length.out=length(labs

Re: [R] barplot

2012-05-23 Thread bets
Thank you for the answer. I tried the first suggestion, but that didn't work (length didn't match again), unless I'm doing something wrong. The stacklab function is nice, but still I'm having way to much labels. Maybe the actual graph makes it more clear: http://r.789695.n4.nabble.com/file/n46310

Re: [R] barplot

2012-05-23 Thread Jim Lemon
On 05/23/2012 09:34 PM, bets wrote: Hey, I am trying to create barplot of abundances over time (in days). The period is over 171 days, so I don't want to have all labels there but only the first day of the month. I couldn't find anything like this on the forum yet. Mostrly it's about year to yea

Re: [R] barplot: legend: two rows

2012-05-22 Thread Marion Wenty
Hello Uwe, thanks for drawing this to my attention! I tried it again without adding another empty legend element and it worked - yes, the second row not being visible was my problem. Now it works! Thanks again, Marion 2012/5/15 Uwe Ligges > > > On 15.05.2012 17:38, Marion Wenty wrote: > >> Hel

Re: [R] barplot: legend: two rows

2012-05-15 Thread Uwe Ligges
On 15.05.2012 17:38, Marion Wenty wrote: Hello, I solved my problem with the uneven numbers of legend elements, which should be put into more than one rows, in the following way: I added another legend element which is empty ("") and is filled with "white": legend(0,-1.4,xjust=0,ncol=3,legen

Re: [R] barplot: legend: two rows

2012-05-15 Thread Marion Wenty
Hello, I solved my problem with the uneven numbers of legend elements, which should be put into more than one rows, in the following way: I added another legend element which is empty ("") and is filled with "white": legend(0,-1.4,xjust=0,ncol=3,legend=c(colnames(dat)[-1],""),fill=c("navyblue","

Re: [R] barplot: legend: two rows

2012-05-11 Thread Marion Wenty
Hello, thank you very much for your answers. Using the command ncol worked in my special case, if I have got a legend with 4 elements, but with 5 it doesn't work. I am using two functions which I had created and checked what might be the difference, so that the second one doesn't work, but I could

Re: [R] barplot: legend: two rows

2012-05-09 Thread Uwe Ligges
On 09.05.2012 13:23, Marion Wenty wrote: dear r-helpers, i have got another question: i am using the functions par(xpd=T) legend to create a legend below the x-axis. i used the parameter horiz=T. now i would like to put the elements of the legend in two rows: e.g. if my legend has got 5 e

Re: [R] Barplot problem

2012-04-20 Thread Mark Lamias
Here is an example you can use:  #Generate random normal variables to use as dummy data for Fisher's Alpha alphaBCI<-rnorm(100)   #Assume you have 5 sites, each with 20 data points sites<-rep(c("Site 1", "Site 2", "Site 3", "Site 4", "Site 5"), each=20)   #Making sites a factor will produce the str

Re: [R] barplot on map

2012-03-22 Thread Peter Ehlers
Check out the subplot() function in the TeachingDemos package. Peter Ehlers On 2012-03-22 12:28, Martin Renner wrote: I used the function stars() to make barplot-like plots on a map. Now editor wants us to use more traditional vertical barplots. Does anybody already have some code that would

Re: [R] barplot and NA

2012-03-12 Thread John D. Muccigrosso
On 12 Mar 2012, at 12:47 , S Ellison wrote: > Yes, to the extent that the default barplot plots the height of the bar so > far as the sum of teh values so far, starting at teh first. For your first > vector, no problem; for your second, the highest value is undefiuned, for the > third, the sum

Re: [R] barplot and NA

2012-03-12 Thread S Ellison
> -Original Message- > Am I wrong that barplot is supposed to just skip NAs, and > continue with the rest of the data in a matrix column? That's > how I read various posts on the subject. > > But that's not what happens for me with R64.app (on a Mac, > obviously). For example: > > d

Re: [R] barplot and NA

2012-03-12 Thread ilai
d2 <- as.matrix(c(2,NA,4)) barplot(d2,beside=T) barplot(c(d2)) barplot(na.omit(d2)) d2[2,] <- 0 barplot(d2) # So barplot is not "stopping" at the first NA (first 2 plots). But what does stacking even mean when you have a missing group in the middle ? you can't expect barplot to know... if yo

Re: [R] barplot with both color and shading

2012-02-22 Thread Shi, Tao
Thank you both, Michael and Jim, for the answers! - Original Message - > From: Michael Bibo > To: r-h...@stat.math.ethz.ch > Cc: > Sent: Wednesday, February 22, 2012 12:46 AM > Subject: Re: [R] barplot with both color and shading > > Shi, Tao yahoo.com> wr

Re: [R] barplot with both color and shading

2012-02-22 Thread Michael Bibo
Shi, Tao yahoo.com> writes: > > Hi list, > > I want to draw a bar plot with color indicating one grouping and different shading on top of the color > indicating another grouping.  How should I proceed? > > Thanks! > > ...Tao > > Does this help? http://finzi.psych.upenn.edu/Rhelp10/2010-Sep

Re: [R] barplot with both color and shading

2012-02-21 Thread Jim Lemon
On 02/22/2012 09:24 AM, Shi, Tao wrote: Hi list, I want to draw a bar plot with color indicating one grouping and different shading on top of the color indicating another grouping. How should I proceed? Hi Tao, You can build a barplot with the rectFill function (plotrix), but it is not a ma

Re: [R] barplot with both color and shading

2012-02-21 Thread Shi, Tao
tempt: barplot(1:10, angle=20, density=c(0,20), col=rep(0:1, each=5)) ...Tao - Original Message - > From: R. Michael Weylandt > To: "Shi, Tao" > Cc: "r-help@r-project.org" > Sent: Tuesday, February 21, 2012 6:49 PM > Subject: Re: [R] barplot with both

Re: [R] barplot with both color and shading

2012-02-21 Thread R. Michael Weylandt
This seems like a natural fit for ggplot2 graphics, but I'm not aware of shading as a widely implemented graphical element: this might have some useful information -- http://had.co.nz/ggplot2/geom_histogram.html Can you find an example of "shading" in R? (perhaps in the R Graphics Gallery) If you

Re: [R] barplot with more than 1 variable

2012-02-19 Thread Jim Lemon
On 02/19/2012 11:31 PM, Francesco Sarracino wrote: Dear R listers, I am trying to produce a simple (for a stata user) barplot with 4 countries on the x axis, each country observed in 2 subsequent years and 3 variables. Basically, I should have three bars for each year for each country. I am attac

Re: [R] barplot with more than 1 variable

2012-02-19 Thread ilai
You could have found the solution in http://had.co.nz/ggplot2/geom_bar.html yourself since all help pages for ggplot refer you to the web site. But to speed things up for you, try this for starters: TUSE2 <- data.frame(country = rep(c("United States","Italy","Germany","Netherlands"),each=2), year3

Re: [R] barplot ignoring col parameter

2011-12-05 Thread R. Michael Weylandt
barplot() defaults to stacked bars for matrices and uses the colors fresh for each bar: e.g., layout(1:2) barplot(matrix(1:6, 2), col = c("red", "blue","green")) barplot(matrix(1:6, 3), col = c("red", "blue","green")) To get what you are looking for, try something like this: x = matrix(1:6,1); c

Re: [R] barplot ignoring col parameter

2011-12-05 Thread Federico Calboli
On 5 Dec 2011, at 15:58, R. Michael Weylandt wrote: > x <- c(2L, 108L, 0L, 0L, 0L, 1L, 3L, 0L, 0L, 0L, 0L, 0L, 7L, 18L, > 3L, 4L, 8L, 20L, 26L, 20L, 19L, 7L, 1L, 1L) > mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2), > rep('white', 5), rep('orange',3), rep('red',9)) > barplot(x, col

Re: [R] barplot ignoring col parameter

2011-12-05 Thread R. Michael Weylandt
x <- c(2L, 108L, 0L, 0L, 0L, 1L, 3L, 0L, 0L, 0L, 0L, 0L, 7L, 18L, 3L, 4L, 8L, 20L, 26L, 20L, 19L, 7L, 1L, 1L) mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2), rep('white', 5), rep('orange',3), rep('red',9)) barplot(x, col = mycol) Produces a multi-colored barplot on my machine so I un

Re: [R] barplot ignoring col parameter

2011-12-05 Thread David Winsemius
On Dec 5, 2011, at 10:44 AM, Federico Calboli wrote: Hi All, I'm having a problem with barplot: mydata [1,] 2 108 0 0 0 1 3 0 0 0 0 0 7 18 3 4 8 20 26 20 19 7 1 1 mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2), rep('white', 5), rep('orange',3), rep('red',

Re: [R] barplot names.arg

2011-11-11 Thread David L Carlson
1:10 PM To: R. Michael Weylandt Cc: r-help@r-project.org Subject: Re: [R] barplot names.arg The documentation for bar plots includes - names.arga vector of names to be plotted below each bar or *group of bars*. If this argument is omitted, then the names are taken from the names attribute of heigh

Re: [R] barplot names.arg

2011-11-10 Thread Diviya Smith
The documentation for bar plots includes - names.arga vector of names to be plotted below each bar or *group of bars*. If this argument is omitted, then the names are taken from the names attribute of height if this is a vector, or the column names if it is a matrix Thanks for your suggestion. Ho

  1   2   3   >