scriptham2
2011-Nov-23 15:50 UTC
[R] Bar charts, frequencies known, intervals of varying width
Hi I would like to plot bar charts in a particular way. The intervals are not evenly distributed and are in a data frame column called size and the relative frequencies are in a second column called mass. Both size and mass are continuous ratio data to all intents and purposes. The data actually represents sieving of sand where $size is sieve aperture and where $mass is the amount remaining on the sieve. So if I sieve 100g of sand through increasingly fine sieves nothing remains on the coarsest sieve say 2500 microns. Between 2000 and 2500 microns there is 0.2g remining on the 2000micron sieve etc. as per the data supplied. size, mass 2500, 0 2000, 0.2 1700, 1.8 1400, 5 1000, 13 800, 40 600, 20 300, 15 180, 3 <180, 2 The data here I have made up for simplicity. In general sands tend to be distributed as lognormal curves and mixtures of sands are combined as the mixture of 2 or more lognormal distributions. I would like to fit 2, 3 or preferably 4 parameter log normal distributions and plot these cumulative distributions on the charts. The problems are: I can't seem to find how to do the bar charts in R and I have not found in the past how to fit 3 or 4 parameter log normal cumulative distributions in R Please help. Thanks Scriptham -- View this message in context: http://r.789695.n4.nabble.com/Bar-charts-frequencies-known-intervals-of-varying-width-tp4100114p4100114.html Sent from the R help mailing list archive at Nabble.com.
Richard M. Heiberger
2011-Nov-23 17:42 UTC
[R] Bar charts, frequencies known, intervals of varying width
Stewart, I am replying to the graphical part of your query. ## This was constructed with ## dump("scriptham2","") ## sso it can be copied directly from the email into an R session. scriptham2 <- structure(list(size = c(2500, 2000, 1700, 1400, 1000, 800, 600, 300, 180, 100), mass = c(0, 0.2, 1.8, 5, 13, 40, 20, 15, 3, 2 )), .Names = c("size", "mass"), row.names = c(NA, 10L), class "data.frame") xyplot(mass ~ size, data=scriptham2, scales=list(x=list(log=TRUE)), horizontal=FALSE, panel=panel.barchart, box.width=.05, origin=0) xyplot(mass ~ size, data=scriptham2, scales=list(x=list(log=TRUE)), type="b", pch=16) I think you are asking for the first graph. I also think that a line graph, as in the second graph, is more appropriate for this type of data. I arbitrarily assigned the "<180" to 100, as it has to have a numerical value on the x-axis. Rich On Wed, Nov 23, 2011 at 10:50 AM, scriptham2 <stewart.porteous@permarock.com> wrote:> Hi > > I would like to plot bar charts in a particular way. The intervals are not > evenly distributed and are in a data frame column called size and the > relative frequencies are in a second column called mass. Both size and mass > are continuous ratio data to all intents and purposes. The data actually > represents sieving of sand where $size is sieve aperture and where $mass is > the amount remaining on the sieve. > > So if I sieve 100g of sand through increasingly fine sieves nothing remains > on the coarsest sieve say 2500 microns. Between 2000 and 2500 microns there > is 0.2g remining on the 2000micron sieve etc. as per the data supplied. > > size, mass > 2500, 0 > 2000, 0.2 > 1700, 1.8 > 1400, 5 > 1000, 13 > 800, 40 > 600, 20 > 300, 15 > 180, 3 > <180, 2 > > The data here I have made up for simplicity. In general sands tend to be > distributed as lognormal curves and mixtures of sands are combined as the > mixture of 2 or more lognormal distributions. > > I would like to fit 2, 3 or preferably 4 parameter log normal distributions > and plot these cumulative distributions on the charts. > > The problems are: I can't seem to find how to do the bar charts in R and > I have not found in the past how to fit 3 or 4 parameter log normal > cumulative distributions in R > > Please help. > Thanks > Scriptham > > -- > View this message in context: > http://r.789695.n4.nabble.com/Bar-charts-frequencies-known-intervals-of-varying-width-tp4100114p4100114.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Jim Lemon
2011-Nov-24 07:38 UTC
[R] Bar charts, frequencies known, intervals of varying width
On 11/24/2011 02:50 AM, scriptham2 wrote:> Hi > > I would like to plot bar charts in a particular way. The intervals are not > evenly distributed and are in a data frame column called size and the > relative frequencies are in a second column called mass. Both size and mass > are continuous ratio data to all intents and purposes. The data actually > represents sieving of sand where $size is sieve aperture and where $mass is > the amount remaining on the sieve. > > So if I sieve 100g of sand through increasingly fine sieves nothing remains > on the coarsest sieve say 2500 microns. Between 2000 and 2500 microns there > is 0.2g remining on the 2000micron sieve etc. as per the data supplied. > > size, mass > 2500, 0 > 2000, 0.2 > 1700, 1.8 > 1400, 5 > 1000, 13 > 800, 40 > 600, 20 > 300, 15 > 180, 3 > <180, 2 > > The data here I have made up for simplicity. In general sands tend to be > distributed as lognormal curves and mixtures of sands are combined as the > mixture of 2 or more lognormal distributions. > > I would like to fit 2, 3 or preferably 4 parameter log normal distributions > and plot these cumulative distributions on the charts. > > The problems are: I can't seem to find how to do the bar charts in R...sands<-read.csv("sands.csv") library(plotrix) barp(sands$mass,names.arg=sands$size,staxx=TRUE) Jim