[R] need of elegant data manipulation
2 0.5730 22.4 THC515 2 0.5930 22.4 THC515 2 0.6130 22.4 THC515 2 0.6330 22.4 THC515 2 0.6530 22.4 THC515 2 0.6830 22.4 THC515 2 0.6940 22.4 THC515 2 0.7140 22.4 THC515 2 0.7340 22.4 THC515 2 0.7540 22.4 THC515 2 0.7740 22.4 THC515 2 0.7940 22.4 THC515 2 0.8140 22.4 THC515 2 0.8340 22.4 THC515 2 0.8540 22.4 -- - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ __ 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] ggplot sub- and superscript for axis name
Hi all, For publication purpose, I require to label ggplot figures axes with sub- or superscript text. I tried several ways, but never worked so far, to mix character string, sub- or superscripting on it and even worse, mathematical symbols. Let say I want to write the LateX equivalent of \gamma_{fi} in a ggplot element name, how can I do that? #dumb example foo-data.frame(a=seq(1:100),b=rnorm(100,1,1)) p-ggplot(data=foo,aes(x=a,y=b)) p-p + geom_point() p-p + scale_x_continuous(name='gamma[fi]') print(p) Regards Ben __ 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] ggplot bar geom: control the filling in the colour legend
Hi all, Is it possible to change the filling of the squares used to represent the colour legend in a bar plot with ggplot? in this example, fillings are raven black, I'd like them white. ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar() Regards -- - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ __ 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] ggplot bar geom: control the filling in the colour legend
Sorry my bad, example too simple try that one out. ggplot(diamonds, aes(clarity, fill=color,colour = cut)) + geom_bar(position = dodge) I want change the filling in the colour legend, not the filling of the bars. Regards Le 10/09/2010 20:41, Ista Zahn a écrit : ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar(fill=white) __ 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] ggplot: stat_smooth() and nls method
Hi all, Does one of you know if there is any way to combine a nls method in the stat_smooth of ggplot? Regards -- - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ __ 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] ggplot bar geom: control the filling in the colour legend
Hi all, I'm still seeking for tweaking the appearance of the color legend in a bar goemetry with ggplot2. I can't seem to control the filling of the colour legend squares take this, ggplot(diamonds, aes(clarity, fill=color,colour = cut)) + geom_bar(position = dodge) and I'd need a white filling in the colour legend, instead of the black one. Does anyone know how to rule that? All the best Le 11/09/2010 10:27, Benoit Boulinguiez a écrit : Sorry my bad, example too simple try that one out. ggplot(diamonds, aes(clarity, fill=color,colour = cut)) + geom_bar(position = dodge) I want change the filling in the colour legend, not the filling of the bars. Regards Le 10/09/2010 20:41, Ista Zahn a écrit : ggplot(diamonds, aes(clarity, colour = cut)) + geom_bar(fill=white) __ 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-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] ggplot: stat_smooth() and nls method
great help, thanks a lot Le 14/09/2010 21:44, Brian Diggs a écrit : On 9/11/2010 7:52 AM, Benoit Boulinguiez wrote: Hi all, Does one of you know if there is any way to combine a nls method in the stat_smooth of ggplot? Regards According to the documentation for predict.nls, it is unable to create standard errors for the predictions, so that has to be turned off in the stat_smooth call. Also, the default formula isn't valid for nls and has to be overridden, and the start values can be passed. I used geom_smooth rather than stat_smooth, but either work. library(ggplot2) DF - data.frame(x=1:20, y=rnorm(20)) ggplot(DF, aes(x=x, y=y)) + geom_smooth(method=nls, formula=y~b*x+c, se=FALSE, start=list(b=0,c=1)) + geom_point() ggplot(DF, aes(x=x, y=y)) + geom_smooth(method=nls, formula=y~sin(b*x), se=FALSE, start=list(b=1)) + geom_point() __ 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] From R to LaTeX to pdf?
Hi Joel, that's a LaTeX issue you have there, nothing wrong with R. You should post your message on a LaTeX Forum about how to use LaTeX. http://www.latex-community.org/ Regards Benoit -Message d'origine- De : r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] De la part de Joel Fürstenberg-Hägg Envoyé : mardi 24 novembre 2009 15:02 À : r-help@r-project.org Objet : [R] From R to LaTeX to pdf? Hi all, Anyone experienced in the LaTeX format? I'm trying to use the xtable package to create nice anova tables, but how do I do to produce a pdf from the resulting LaTeX table? I've tried WinShell and MiKTeX, but I couldn't get any of them working... Here's an example of the output in R: % latex table generated in R 2.9.2 by xtable 1.5-6 package % Tue Nov 24 14:17:32 2009 \begin{tabular}{lr} \hline Df Sum Sq Mean Sq F value Pr($$F) \\ \hline cat 2 40.50 20.25 6.66 0.0019 \\ Residuals 107 325.13 3.04 \\ \hline \end{tabular} Best regards, Joel _ Lagra alla dina foton pe Skydrive. Det dr enkelt och sdkert! http://www.skydrive.live.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.
[R] use of lm() and poly()
Hi all, I want to fit data called metal with a polynominal function as dP ~ a.0 + a.1 * U0 + a.2 * U0^2 + a.3 * U0^3 + a.4 * U0^4 The data set includes, the independant variable U0 and the dependant variable dP. I've seen that the combination of lm() and poly() can do that instead of using the nls() function. But I don't get how to interpret the results from the linear regression, as the coefficients do not match the ones from the nonlinear regression #data metal U0 dP 1 0.00 0 2 0.76 10 3 1.43 20 4 2.56 40 5 3.05 50 6 3.52 60 7 3.76 70 8 4.05 80 9 4.24 90 10 4.47 100 #linear d - seq(0, 4, length.out = 200) for(degree in 1:4) { fm - lm(dP ~ poly(U0, degree), data = metal) assign(paste(metal, degree, sep=.), fm) lines(d, predict(fm, data.frame(U0=d)), col = degree) } metal.4 Call: lm(formula = dP ~ poly(U0, degree), data = metal) Coefficients: (Intercept) poly(U0, degree)1 poly(U0, degree)2 poly(U0, degree)3 poly(U0, degree)4 52.000100.612 19.340 7.101 2.628 #nonlinear fm-nls (dP~ a.0 + a.1*U0 + a.2*U0^2 + a.3*U0^3 + a.4*U0^4, data=metal) Nonlinear regression model model: dP ~ a.0 + a.1 * U0 + a.2 * U0^2 + a.3 * U0^3 + a.4 * U0^4 data: metal a.0 a.1 a.2 a.3 a.4 0.02408 9.81452 5.54269 -2.24657 0.36737 residual sum-of-squares: 5.843 Number of iterations to convergence: 2 Achieved convergence tolerance: 1.378e-06 Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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.
Re: [R] use of lm() and poly()
I guess, I would somehow feel interested that someone out of my field is trying to use the tool I daily manipulate to widen his knowledge or dig further in his own field, though I might at some point recommend him to get back to the basis for some concrete concepts that he wouldn't understand sharply enough. I hope reading Practical Regression and Anova using R by J.J. Faraway will help sharpening out a bit my knowledge's. For sure though, I'd sound less scornful than you. BTW, thank you Daniel for pointing out that I was using orthogonal polynomials instead of regular ones. Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : Bert Gunter [mailto:gunter.ber...@gene.com] Envoyé : mardi 22 décembre 2009 18:26 À : 'Benoit Boulinguiez'; r-help@r-project.org Objet : RE: [R] use of lm() and poly() Get some statistical consulting help or read up on these topics -- any good textbook on regression should contain the necessary material. This has nothing to do with nonlinear regression, so you are confused about the basic ideas. It has nothing to do with R. If you don't understand how the statistical tools work, you shouldn't be using them (without help, anyway). Would you feel comfortable about me playing in your chemistry lab based on my year of college chemistry ~45 years ago? Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Benoit Boulinguiez Sent: Tuesday, December 22, 2009 9:10 AM To: r-help@r-project.org Subject: [R] use of lm() and poly() Hi all, I want to fit data called metal with a polynominal function as dP ~ a.0 + a.1 * U0 + a.2 * U0^2 + a.3 * U0^3 + a.4 * U0^4 The data set includes, the independant variable U0 and the dependant variable dP. I've seen that the combination of lm() and poly() can do that instead of using the nls() function. But I don't get how to interpret the results from the linear regression, as the coefficients do not match the ones from the nonlinear regression #data metal U0 dP 1 0.00 0 2 0.76 10 3 1.43 20 4 2.56 40 5 3.05 50 6 3.52 60 7 3.76 70 8 4.05 80 9 4.24 90 10 4.47 100 #linear d - seq(0, 4, length.out = 200) for(degree in 1:4) { fm - lm(dP ~ poly(U0, degree), data = metal) assign(paste(metal, degree, sep=.), fm) lines(d, predict(fm, data.frame(U0=d)), col = degree) } metal.4 Call: lm(formula = dP ~ poly(U0, degree), data = metal) Coefficients: (Intercept) poly(U0, degree)1 poly(U0, degree)2 poly(U0, degree)3 poly(U0, degree)4 52.000100.612 19.340 7.101 2.628 #nonlinear fm-nls (dP~ a.0 + a.1*U0 + a.2*U0^2 + a.3*U0^3 + a.4*U0^4, data=metal) Nonlinear regression model model: dP ~ a.0 + a.1 * U0 + a.2 * U0^2 + a.3 * U0^3 + a.4 * U0^4 data: metal a.0 a.1 a.2 a.3 a.4 0.02408 9.81452 5.54269 -2.24657 0.36737 residual sum-of-squares: 5.843 Number of iterations to convergence: 2 Achieved convergence tolerance: 1.378e-06 Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Giniral Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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.
[R] curve from a formula with ggplot2
Hi all, I'm smoothly transferring my lattice graphs to ggplot2 graphs, but I'm stuck on representing a curve from a formula. I'm looking for the equivalent of curve() in ggplot2, Hadley Wickham mentions geom_curve, but as far as I've seen in the help it doesn't exist. My need is to plot a regular scatter plot of experimental data (easy to do actually) and then add the fitting model according to a specific formula like y = a*(b*x^n)/(1+b*x^p) where a,b,n and p are known parameters. I guess it's possible and easy to add this layer with ggplot, somehow I didn't find the right function. Any help would be warmly appreciated. Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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.
Re: [R] ggplot2: geom_errorbarh()
Hi, I expect 'width' to set the width of the horizontal line of the whisker, as it does with errobar() Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : hadley wickham [mailto:h.wick...@gmail.com] Envoyé : dimanche 12 juillet 2009 11:04 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R] ggplot2: geom_errorbarh() Hi Benoit, What do you expect width to do? You are already setting the left and right extents with xmin and xmax. Hadley On Thu, Jul 9, 2009 at 10:37 AM, Benoit Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote: Hi all, quick question: is the optional command width effective in the geom_errorbarh() layer of ggplot? Cause I can't get it works on this graph http://www.4shared.com/file/116919103/93488d88/iso_2PrsH.html pdf(file = iso_2PrsH.pdf, width = 7, height = 7) NC60.iso.graph-ggplot( NC60.DATA ,aes(Ce,Qe)) + geom_point(col=MaCouleur1, size=4) + geom_errorbar( aes(ymax = NC60.DATA$Qe+NC60.DATA$sdQe ,ymin=NC60.DATA$Qe-NC60.DATA$sdQe) ,colour=alpha(black,0.4) ,width=1) + geom_errorbarh( aes(xmax = NC60.DATA$Ce+NC60.DATA$sdCe ,xmin=NC60.DATA$Ce-NC60.DATA$sdCe) ,colour=alpha(black,0.4) ,width=1) + geom_line(data=NC60.Res4.curve ,aes(x,y) ,size=1 ,colour=alpha(black,0.5)) + xlab(C[e]~(mmol/m^3)) + ylab(q[e]~(mmol/m^3)) print(NC60.iso.graph) dev.off() Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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. -- http://had.co.nz/ __ 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] ggplot2: geom_errorbarh()
when I use size, it sets the global size of the whiskers (I'd rather say the thickness of the line) but for sure it does not set the width of the whisker. Try to use the option 'width' with errorbar() not errorbarh(), you'll see that it works perfectly, it sets the width of the whisker. It just doesn't work with errorbarh(), I guess... unfortunately... Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : hadley wickham [mailto:h.wick...@gmail.com] Envoyé : mercredi 15 juillet 2009 14:52 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R] ggplot2: geom_errorbarh() In ggplot2, you'll want to use size. Hadley On Wed, Jul 15, 2009 at 12:36 PM, Benoit Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote: Hi, I expect 'width' to set the width of the horizontal line of the whisker, as it does with errobar() Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : hadley wickham [mailto:h.wick...@gmail.com] Envoyé : dimanche 12 juillet 2009 11:04 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R] ggplot2: geom_errorbarh() Hi Benoit, What do you expect width to do? You are already setting the left and right extents with xmin and xmax. Hadley On Thu, Jul 9, 2009 at 10:37 AM, Benoit Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote: Hi all, quick question: is the optional command width effective in the geom_errorbarh() layer of ggplot? Cause I can't get it works on this graph http://www.4shared.com/file/116919103/93488d88/iso_2PrsH.html pdf(file = iso_2PrsH.pdf, width = 7, height = 7) NC60.iso.graph-ggplot( NC60.DATA ,aes(Ce,Qe)) + geom_point(col=MaCouleur1, size=4) + geom_errorbar( aes(ymax = NC60.DATA$Qe+NC60.DATA$sdQe ,ymin=NC60.DATA$Qe-NC60.DATA$sdQe) ,colour=alpha(black,0.4) ,width=1) + geom_errorbarh( aes(xmax = NC60.DATA$Ce+NC60.DATA$sdCe ,xmin=NC60.DATA$Ce-NC60.DATA$sdCe) ,colour=alpha(black,0.4) ,width=1) + geom_line(data=NC60.Res4.curve ,aes(x,y) ,size=1 ,colour=alpha(black,0.5)) + xlab(C[e]~(mmol/m^3)) + ylab(q[e]~(mmol/m^3)) print(NC60.iso.graph) dev.off() Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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. -- http://had.co.nz/ -- http://had.co.nz/ __ 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] curve from a formula with ggplot2
Hi, It works perfectly! Though I'm still stuck on the height of the whiskers with errorbarh() :) Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : hadley wickham [mailto:h.wick...@gmail.com] Envoyé : dimanche 12 juillet 2009 11:09 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R] curve from a formula with ggplot2 Hi Benoit, Have a look at http://had.co.nz/ggplot2/stat_function.html. Does that help? Hadley On Tue, Jul 7, 2009 at 11:15 AM, Benoit Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote: Hi all, I'm smoothly transferring my lattice graphs to ggplot2 graphs, but I'm stuck on representing a curve from a formula. I'm looking for the equivalent of curve() in ggplot2, Hadley Wickham mentions geom_curve, but as far as I've seen in the help it doesn't exist. My need is to plot a regular scatter plot of experimental data (easy to do actually) and then add the fitting model according to a specific formula like y = a*(b*x^n)/(1+b*x^p) where a,b,n and p are known parameters. I guess it's possible and easy to add this layer with ggplot, somehow I didn't find the right function. Any help would be warmly appreciated. Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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. -- http://had.co.nz/ __ 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] tweak a bit the legend wiht ggplot2
Hi all, I've this ggplot2 graph (http://www.4shared.com/file/120101043/f3e9350/isotherm.html). I'd like to tweak the legend for the adsorbent part. I'd like to have full square of the colors instead of the full circles. I guess that I've to work on the scale_color_hue or fill somewhere but I haven't found my way yet. Here is my code to get the graph: pdf(isotherm.pdf,width=7,height=6) #windows(width=7,height=6) ads.graph-ggplot(Adsorp.DATA,aes(relative.p,ads.vol,shape=type ,color=adsorbent))+ geom_point(size=I(3)) + labs(x=expression(p/p[0]),y=N[2]~adsorbed~volume~(cc/g)) + scale_shape(name=Adsorption\nProcedure ,solid=F ,breaks=c(A,D) ,labels=c(Adsorp.,Desorp.) ) + scale_colour_hue(name=Adsorbent) + scale_x_continuous(limits=c(0,1),minor_breaks = seq(0,1,0.1)) + scale_y_continuous(limits=c(0,1000)) + opts(panel.grid.minor = theme_line(colour = grey94)) print(ads.graph) dev.off() Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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.
[R] nls convergence trouble
Hi, Parameters assessment in R with nls doesn't work, though it works fine with MS Excel with the internal solver :( I use nls in R to determine two parameters (a,b) from experimental data. m VC0 CeQe 1 0.0911 0.0021740 3987.581 27.11637 94.51206 2 0.0911 0.0021740 3987.581 27.41915 94.50484 3 0.0911 0.0021740 3987.581 27.89362 94.49352 4 0.0906 0.0021740 5981.370 82.98477 189.37739 5 0.0906 0.0021740 5981.370 84.46435 189.34188 6 0.0906 0.0021740 5981.370 85.33213 189.32106 7 0.0911 0.0021740 7975.161 192.54276 233.30310 8 0.0911 0.0021740 7975.161 196.52891 233.20797 9 0.0911 0.0021740 7975.161 203.07467 233.05176 10 0.0906 0.0021872 9968.951 357.49157 328.29824 11 0.0906 0.0021872 9968.951 368.47609 328.03306 12 0.0906 0.0021872 9968.951 379.18904 327.77444 13 0.0904 0.0021740 13956.532 1382.61955 350.33391 14 0.0904 0.0021740 13956.532 1389.64915 350.16485 15 0.0904 0.0021740 13956.532 1411.87726 349.63030 16 0.0902 0.0021740 15950.322 2592.90486 367.38460 17 0.0902 0.0021740 15950.322 2606.34599 367.06064 18 0.0902 0.0021740 15950.322 2639.54301 366.26053 19 0.0906 0.0021872 17835.817 3894.12224 336.57036 20 0.0906 0.0021872 17835.817 3950.35273 335.21289 21 0.0906 0.0021872 17835.817 3972.29367 334.68320 the model LgmAltformula is Qe ~ (V + b * m * a + C0 * V * b - ((C0 * V * b)^2 + 2 * C0 * b * V^2 - 2 * C0 * V * m * a * b^2 + V^2 + 2 * V * m * a * b + (b * m * a)^2)^(1/2))/(2 * b * m) the command in R is nls(formula=LgmAltFormula,data=bois.DATA,start=list(a=300,b=0.01),trace=TRUE ,control=nls.control(minFactor=0.9)) R has difficulties to converge and stops after the maximum of iterations 64650.47 : 2.945876e+02 3.837609e+08 64650.45 : 2.945876e+02 4.022722e+09 64650.45 : 2.945876e+02 1.695669e+09 64650.45 : 2.945876e+02 5.103971e+08 64650.44 : 2.945876e+02 8.497431e+08 64650.41 : 2.945876e+02 1.515243e+09 64650.36 : 2.945877e+02 5.482744e+09 64650.36 : 2.945877e+02 2.152294e+09 64650.36 : 2.945877e+02 7.953167e+08 64650.35 : 2.945877e+02 7.62e+07 Erreur dans nls(formula = LgmAltFormula, data = bois.DATA, start = list(a = 300, : le nombre d'itérations a dépassé le maximum de 50 The parameters a and b are estimated to be 364 and 0.0126 with Excel with the same data set. I tried with the algorithm=port with under and upper limits. One of the parameter reaches the limit and the regression stops. How can I succeed with R to make this regression? Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Campus de Beaulieu, 263 Avenue du Général Leclerc 35700 Rennes, France Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ [[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.
Re: [R] nls convergence trouble
Hi, I agree with you that Excel is not the best tool for fittings, that's why I try to handle R. But I need to use this specific model (LgmAltFormula) and not a polynomial expression with the different parameters even if your method produced correct fitting. The parameters a and b are the Langmuir parameters that describe the adsorption of a compound onto activated carbon. I need to assess these parameters. Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : Petr PIKAL [mailto:[EMAIL PROTECTED] Envoyé : mercredi 3 septembre 2008 17:58 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Odp: [R] nls convergence trouble Hi Excel fit is not exceptionally good. Try fff-function(a,b) (V + b * m * a + C0 * V * b - ((C0 * V * b)^2 + 2 * C0 * + b * V^2 - 2 * C0 * V * m * a * b^2 + V^2 + 2 * V * m * a * + b + (b * m * a)^2)^(1/2))/(2 * b * m) and with attached data frame plot(Qe,fff(364,0.0126)) abline(0,1) you clearly see linear relationship in smaller values but quite chaotic behaviour in bigger ones (or big deviation of experimental points from your model). So it is up to you if you want any fit (like from Excel) or only a good one (like from R). Seems to me that simple linear could be quite a good choice although there is some nelinearity. fit-lm(Qe~Ce+C0+V+m) summary(fit) Call: lm(formula = Qe ~ Ce + C0 + V + m) Residuals: Min 1Q Median 3Q Max -16.654 -8.653 2.426 9.971 11.912 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) -8.148e+02 1.330e+03 -0.613 0.549254 Ce -6.894e-02 4.982e-03 -13.839 6.02e-10 *** C0 3.284e-02 1.676e-03 19.589 4.26e-12 *** V2.153e+06 4.607e+05 4.674 0.000300 *** m -4.272e+04 1.218e+04 -3.509 0.003167 ** --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Residual standard error: 10.87 on 15 degrees of freedom Multiple R-squared: 0.9903, Adjusted R-squared: 0.9877 F-statistic: 381.3 on 4 and 15 DF, p-value: 6.91e-15 plot(predict(fit), Qe) abline(0,1) Regards Petr [EMAIL PROTECTED] napsal dne 03.09.2008 16:01:36: Hi, Parameters assessment in R with nls doesn't work, though it works fine with MS Excel with the internal solver :( I use nls in R to determine two parameters (a,b) from experimental data. m VC0 CeQe 1 0.0911 0.0021740 3987.581 27.11637 94.51206 2 0.0911 0.0021740 3987.581 27.41915 94.50484 3 0.0911 0.0021740 3987.581 27.89362 94.49352 4 0.0906 0.0021740 5981.370 82.98477 189.37739 5 0.0906 0.0021740 5981.370 84.46435 189.34188 6 0.0906 0.0021740 5981.370 85.33213 189.32106 7 0.0911 0.0021740 7975.161 192.54276 233.30310 8 0.0911 0.0021740 7975.161 196.52891 233.20797 9 0.0911 0.0021740 7975.161 203.07467 233.05176 10 0.0906 0.0021872 9968.951 357.49157 328.29824 11 0.0906 0.0021872 9968.951 368.47609 328.03306 12 0.0906 0.0021872 9968.951 379.18904 327.77444 13 0.0904 0.0021740 13956.532 1382.61955 350.33391 14 0.0904 0.0021740 13956.532 1389.64915 350.16485 15 0.0904 0.0021740 13956.532 1411.87726 349.63030 16 0.0902 0.0021740 15950.322 2592.90486 367.38460 17 0.0902 0.0021740 15950.322 2606.34599 367.06064 18 0.0902 0.0021740 15950.322 2639.54301 366.26053 19 0.0906 0.0021872 17835.817 3894.12224 336.57036 20 0.0906 0.0021872 17835.817 3950.35273 335.21289 21 0.0906 0.0021872 17835.817 3972.29367 334.68320 the model LgmAltformula is Qe ~ (V + b * m * a + C0 * V * b - ((C0 * V * b)^2 + 2 * C0 * b * V^2 - 2 * C0 * V * m * a * b^2 + V^2 + 2 * V * m * a * b + (b * m * a)^2)^(1/2))/(2 * b * m) the command in R is nls(formula=LgmAltFormula,data=bois.DATA,start=list(a=300,b=0.01),trace=TRUE ,control=nls.control(minFactor=0.9)) R has difficulties to converge and stops after the maximum of iterations 64650.47 : 2.945876e+02 3.837609e+08 64650.45 : 2.945876e+02 4.022722e+09 64650.45 : 2.945876e+02 1.695669e+09 64650.45 : 2.945876e+02 5.103971e+08 64650.44 : 2.945876e+02 8.497431e+08 64650.41 : 2.945876e+02 1.515243e+09 64650.36 : 2.945877e+02 5.482744e+09 64650.36 : 2.945877e+02 2.152294e+09 64650.36 : 2.945877e+02 7.953167e+08 64650.35 : 2.945877e+02 7.62e+07 Erreur dans nls(formula = LgmAltFormula, data = bois.DATA, start = list(a = 300, : le nombre d'itérations a dépassé le maximum de 50 The parameters a and b are estimated to be 364 and 0.0126 with Excel with the same data set. I tried with the algorithm=port with under and upper limits. One of the parameter reaches the limit and the regression stops. How can I succeed with R to make this regression? Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Campus de Beaulieu, 263 Avenue du Général Leclerc
[R] writing simple function through script
Hi all, I try to write a simple function in a script. The script is as follows yo-function(Xdata) { n-length(Xdata[,1]) Lgm-nls(formula=LgmFormula, data=Xdata, start=list(a=1500,b=0.1),weights=Xdata$Qe) return(Lgm) } After the execution of the script, when I call the function yo on data called NC60.DATA I get an error. #yo(NC60.DATA) Erreur dans eval(expr, envir, enclos) : objet Xdata not found The object Xdata isn't found. Why? Is that possible to debug a function with R? Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Campus de Beaulieu, 263 Avenue du Général Leclerc 35700 Rennes, France Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ [[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.
[R] axis text size in scatter plot
Hi, Quite simple question I guess. Where could we specify the size of the text (axis,legend) for a scatter plot graphic made with plot()? Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Campus de Beaulieu, 263 Avenue du Général Leclerc 35700 Rennes, France Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ [[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.
[R] superscript text style in axis label in graph
Hi all, I'd like to use superscript or subscript in the axis label of a graph. Is that possible in R? For instance in xlab=Ce (mmol/m3), I'd need the 3 of cubic meter in superscript. Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Campus de Beaulieu, 263 Avenue du Général Leclerc 35700 Rennes, France Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ [[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.
[R] ode first step
Hi all, I try to assess the parameters (K1,K2) of a model that describes the adsorption of a molecule onto on adsorbent. equation: dq/dt = K1*C*(qm-q)-K2*q I know the value of 'qm' and I experimentally measure the variables 'q', 'C', and the time 't'. t C q 1 0 144.05047 0.000 2565 99.71492 0.1105625 3988 74.99426 0.1722100 4 1415 58.65572 0.2129545 5 1833 48.34586 0.2386649 6 2257 40.29413 0.2587440 7 2675 32.92470 0.2771216 8 3105 29.57162 0.2854834 9 3552 28.01424 0.2893672 10 3986 25.62167 0.2953337 11 4415 23.62612 0.3003101 12 4841 21.95523 0.3044769 13 5264 21.08464 0.3066480 14 5698 19.68040 0.3101498 15 6509 18.31788 0.3135476 16 6950 17.65868 0.3151915 17 7403 17.00206 0.3168290 18 8130 16.38856 0.3183589 19 9001 15.58544 0.3203617 20 9928 15.27882 0.3211263 21 11899 14.46415 0.3231579 22 16354 13.91779 0.3245204 23 18926 13.82630 0.3247485 24 21602 13.66776 0.3251439 25 24413 13.98560 0.3243513 26 27056 13.87143 0.3246360 27 29844 13.64881 0.3251912 It's a differential equation, thus I had a look on the command 'ode' from the deSolve package. I'm early stuck on the use of the function 'ode' cause I don't get how to define the function 'func' required by 'ode' Any help would be appreciated. Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ __ 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] ode first step
As I do not thoroughly understand the way 'lsoda' works, I face some difficulties to 'get' myself into the function(), though I changed the code as follows: -- require(deSolve) qm-0.36 y0-c(0) parms-c(K1,K2) times-seq(0,1,1) kinetic.model-function(t,y,parms){ dq.dt = K1*C0 - (K1*m/V+ K2)*q list(dq.dt) } foo-lsoda(y0,times,kinetic.model,parms) Error in func(time, state, parms, ...) : object 'K1' not found -- 'K1' and 'K2' are parameters but 'C' is not a parameter, it's a dependant variable of the time. I actually express it as a function of q(t) to get this new equation dq/dt= K1*C0 - (K1*m/V+ K2)*q(t) where K1 and K2 are the unknown but desired parameters and {C0,m,V} are constant known values. Nevertheless, I still get this 'Error about object 'K1' not found'. Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : Dieter Menne [mailto:dieter.me...@menne-biomed.de] Envoyé : jeudi 14 mai 2009 12:12 À : 'Benoit Boulinguiez' Objet : RE: [R] ode first step Try to hide yourself inside the function(). What would you see? No K1, for sure, no C, no K2. These are passed through parms, so parms[K1] would work, but not for C, you should add it. -Original Message- From: Benoit Boulinguiez [mailto:benoit.boulingu...@ensc-rennes.fr] Sent: Thursday, May 14, 2009 11:53 AM To: 'Dieter Menne' Subject: RE: [R] ode first step -- qm-0.36 y0-c(0) parms-c(K1=1,K2=1) times-seq(0,1,1) kinetic.model-function(t,y,parms){ dq.dt- K1*C*(qm-q)-K2*q list(dq.dt) } require(deSolve) nls(foo-lsoda(y0,times,kinetic.model,parms) __ 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] ode first step
Thanks to Dieter Menne and Spencer Graves I started to get my way through lsoda() Now I need to use it in the nls() to assess the parameter. I've tried with a basic example dy/dt = K1*conc I try to assess the value of K1 from a simulated data set with a K1 close to 2. I'm not sure that I'm using nls() and lsoda() correctly. Here is (I think) the best code that I've done so far even though it crashes when I call nls() -- x-seq(0,10,,100) y-exp(2*x) y-rnorm(y,y,0.3*y) test.model-function(t,conc,parms){ dy.dt = parms[K1]*conc list(dy.dt) } require(deSolve) foo-lsoda(c(conc=1),times=seq(0,10,,100),test.model,parms=c(K1=2)) foo #use of nls func-function(K1) { foo-lsoda(c(conc=1),times=seq(0,10,,100),test.model,parms=c(K1=K1)) foo[,conc] } nls(foo~func(K1),start=list(K1=1),data=data.frame(foo=y)) # have a look on the SSD # y is the vector of real data SSD-function(K1) { sum((y-func(K1))^2) } data-seq(1.5,2.1,,100) plot(data,sapply(data,SSD),type=l) -- Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : spencerg [mailto:spencer.gra...@prodsyse.com] Envoyé : vendredi 15 mai 2009 05:28 À : Benoit Boulinguiez Cc : dieter.me...@menne-biomed.de; r-help@r-project.org Objet : Re: [R] ode first step Have you looked at the vignette in the deSolve package? (deS - vignette('compiledCode')) # opens a pdf file Stangle(deS$file) # writes an R script file to getwd() In spite of the name, this vignette includes an example entirely in R. By comparing it with your code, I see that you do NOT provide a connection between y, parms, K1, C0, m, V, K2 and q. Something like the following might work: kinetic.model-function(t,y,parms){ dq.dt = parms['K1']*y['C0'] - (parms['K1']*y['m']/y['V']+ parms['K2'])*y['q'] list(dq.dt) } This may not be correct, but I hope the changes will help you see how to make it work. Bon Chance. Spencer Graves Benoit Boulinguiez wrote: As I do not thoroughly understand the way 'lsoda' works, I face some difficulties to 'get' myself into the function(), though I changed the code as follows: -- require(deSolve) qm-0.36 y0-c(0) parms-c(K1,K2) times-seq(0,1,1) kinetic.model-function(t,y,parms){ dq.dt = K1*C0 - (K1*m/V+ K2)*q list(dq.dt) } foo-lsoda(y0,times,kinetic.model,parms) Error in func(time, state, parms, ...) : object 'K1' not found -- 'K1' and 'K2' are parameters but 'C' is not a parameter, it's a dependant variable of the time. I actually express it as a function of q(t) to get this new equation dq/dt= K1*C0 - (K1*m/V+ K2)*q(t) where K1 and K2 are the unknown but desired parameters and {C0,m,V} are constant known values. Nevertheless, I still get this 'Error about object 'K1' not found'. Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : Dieter Menne [mailto:dieter.me...@menne-biomed.de] Envoyé : jeudi 14 mai 2009 12:12 À : 'Benoit Boulinguiez' Objet : RE: [R] ode first step Try to hide yourself inside the function(). What would you see? No K1, for sure, no C, no K2. These are passed through parms, so parms[K1] would work, but not for C, you should add it. -Original Message- From: Benoit Boulinguiez [mailto:benoit.boulingu...@ensc-rennes.fr] Sent: Thursday, May 14, 2009 11:53 AM To: 'Dieter Menne' Subject: RE: [R] ode first step -- qm-0.36 y0-c(0) parms-c(K1=1,K2=1) times-seq(0,1,1) kinetic.model-function(t,y,parms){ dq.dt- K1*C*(qm-q)-K2*q list(dq.dt) } require(deSolve) nls(foo-lsoda(y0,times,kinetic.model,parms) __ 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-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] using lsoda() and nls() together
Thanks to Dieter Menne and Spencer Graves I started to get my way through lsoda() Now I need to use it in with nls() to assess parameters I have a go with a basic example dy/dt = K1*conc I try to assess the value of K1 from a simulated data set with a K1 close to 2. Here is (I think) the best code that I've done so far even though it crashes when I call nls() -- x-seq(0,10,,100) y-exp(2*x) y-rnorm(y,y,0.3*y) test.model-function(t,conc,parms){ dy.dt = parms[K1]*conc list(dy.dt) } require(deSolve) foo-lsoda(c(conc=1),times=seq(0,10,,100),test.model,parms=c(K1=2)) foo #use of nls func-function(K1) { foo-lsoda(c(conc=1),times=seq(0,10,,100),test.model,parms=c(K1=K1)) foo[,conc] } nls(foo~func(K1),start=list(K1=1),data=data.frame(foo=y)) # have a look on the SSD # y is the vector of real data SSD-function(K1) { sum((y-func(K1))^2) } data-seq(1.5,2.1,,100) plot(data,sapply(data,SSD),type=l) -- Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : spencerg [mailto:spencer.gra...@prodsyse.com] Envoyé : vendredi 15 mai 2009 05:28 À : Benoit Boulinguiez Cc : dieter.me...@menne-biomed.de; r-help@r-project.org Objet : Re: [R] ode first step Have you looked at the vignette in the deSolve package? (deS - vignette('compiledCode')) # opens a pdf file Stangle(deS$file) # writes an R script file to getwd() In spite of the name, this vignette includes an example entirely in R. By comparing it with your code, I see that you do NOT provide a connection between y, parms, K1, C0, m, V, K2 and q. Something like the following might work: kinetic.model-function(t,y,parms){ dq.dt = parms['K1']*y['C0'] - (parms['K1']*y['m']/y['V']+ parms['K2'])*y['q'] list(dq.dt) } This may not be correct, but I hope the changes will help you see how to make it work. Bon Chance. Spencer Graves Benoit Boulinguiez wrote: As I do not thoroughly understand the way 'lsoda' works, I face some difficulties to 'get' myself into the function(), though I changed the code as follows: -- require(deSolve) qm-0.36 y0-c(0) parms-c(K1,K2) times-seq(0,1,1) kinetic.model-function(t,y,parms){ dq.dt = K1*C0 - (K1*m/V+ K2)*q list(dq.dt) } foo-lsoda(y0,times,kinetic.model,parms) Error in func(time, state, parms, ...) : object 'K1' not found -- 'K1' and 'K2' are parameters but 'C' is not a parameter, it's a dependant variable of the time. I actually express it as a function of q(t) to get this new equation dq/dt= K1*C0 - (K1*m/V+ K2)*q(t) where K1 and K2 are the unknown but desired parameters and {C0,m,V} are constant known values. Nevertheless, I still get this 'Error about object 'K1' not found'. Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : Dieter Menne [mailto:dieter.me...@menne-biomed.de] Envoyé : jeudi 14 mai 2009 12:12 À : 'Benoit Boulinguiez' Objet : RE: [R] ode first step Try to hide yourself inside the function(). What would you see? No K1, for sure, no C, no K2. These are passed through parms, so parms[K1] would work, but not for C, you should add it. -Original Message- From: Benoit Boulinguiez [mailto:benoit.boulingu...@ensc-rennes.fr] Sent: Thursday, May 14, 2009 11:53 AM To: 'Dieter Menne' Subject: RE: [R] ode first step -- qm-0.36 y0-c(0) parms-c(K1=1,K2=1) times-seq(0,1,1) kinetic.model-function(t,y,parms){ dq.dt- K1*C*(qm-q)-K2*q list(dq.dt) } require(deSolve) nls(foo-lsoda(y0,times,kinetic.model,parms) __ 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-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] text in graph with expression
Hi all, I'm using 'expression' in the axes labels in graphs to get the greek letters (ylab), as follows: plot( layer_1$U0 ,layer_1$dP/(H1.Theo) #,ylim=c(0,100) ,xlim=c(0,1.1) #,main=Pressure Drop, ,xlab=expression(U[0]~(Nm/s)) ,ylab=expression(Delta~P~(Pa/m)) ,col=2 ,pch=16 ,cex=1.5) I just need to know how to avoid the use of a space (~) between the greek letter (Delta) and the rest of the text. Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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.
[R] par() default values
Hi all, Is that possible to get back to the par() default values easily? I played a bit with par() Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Campus de Beaulieu, 263 Avenue du Général Leclerc 35700 Rennes, France Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ [[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.
[R] parameter assessment in differential equation
Hi, I'd like to know whether R is capable to assess parameters in a model describing the kinetic of a pollutant adsorption onto activated carbon. A common relation is for instance the Adam-Bohart-Thomas' one: dx/dt = K1 * (qm-x)*C - K2x where {K1,K2} are the unknown paramters and {qm,C} are known parameters Of course I get experimental data sets of measured x as a function of time. If R can help to handle that, which functions have to be used (diff, optim, nls...) Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Campus de Beaulieu, 263 Avenue du Général Leclerc 35700 Rennes, France Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ [[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.
Re: [R] R plot
Hi, Personally I always use xlim and ylim with the plot or points function like that: plot( X,Y,pch=16,col=2,cex.axis=1.5,cex.lab=1.5, xlim=c(0,1.05*max(X)),ylim=c(0,1.05*max(Y)) ) Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Wacek Kusnierczyk Envoyé : vendredi 17 octobre 2008 10:47 À : Haoda Fu Cc : R help Objet : Re: [R] R plot Haoda Fu wrote: All - When I plot something like a-rnorm(5) b-rnorm(5) plot(a,b,col = red) points(10,-10) The last point is missing because it is out of range of the first plot. I just try to switch from Matlab to R. In Matlab, it always can automatic adjust the xlim and ylim for such case. Is it possible auto adjust in R? Otherwise keep tracking xlim and ylim is really annoying. if you know the range in advance, you can specify it using the xlim and ylim parameters to plot. you can also use them in points (it doesn't cause an error), but it does not seem to have the desired effect of reshaping the plot. it's perhaps a pity it works this way, but you have to get used to it. or drop r if you find matlab better. vQ __ 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-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] use of empty space in split graph device
Hi all, I divide the graphical device into 4 ---mfrow=c(2,2)--- to plot 3 boxplots graph. Thus I get an empty space for the fourth graph. I d'like to place a legend in this space. legend() creates a legend in the last graph (the 3rd) I'd like a legend in the empty space. How may I do it? #graph parameter par( fin=c(6,6), #dim graph mai=c(1,1,0.5,0.5) #marges graph ,mfrow=c(2,2) ) #boxplots boxplot(x) title(main=expression(1- residuals distribution)) abline(0,0,lwd=2,col=2) boxplot(x) title(main=expression(2- residuals distribution)) abline(0,0,lwd=2,col=2) boxplot(x) title(main=expression(3- residuals distribution)) abline(0,0,lwd=2,col=2) Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Campus de Beaulieu, 263 Avenue du Général Leclerc 35700 Rennes, France Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ [[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.
Re: [R] use of empty space in split graph device
That's it. thanks Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : Greg Snow [mailto:[EMAIL PROTECTED] Envoyé : vendredi 17 octobre 2008 19:19 À : Benoit Boulinguiez; r-help@r-project.org Objet : RE: [R] use of empty space in split graph device The plot.new function will start a new plot in the next frame, but not plot anything. By default the coordinates go from 0 to 1 in both the x and y directions. Try: par(mfrow=c(2,2)) boxplot(rnorm(100)) boxplot(runif(100)) boxplot(rexp(100, 1/3)) plot.new() legend( 0,1, pch=1:3, legend=c('a','b','c'), lty=1, col=c('red','green','blue')) Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] 801.408.8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Benoit Boulinguiez Sent: Friday, October 17, 2008 7:30 AM To: r-help@r-project.org Subject: [R] use of empty space in split graph device Hi all, I divide the graphical device into 4 ---mfrow=c(2,2)--- to plot 3 boxplots graph. Thus I get an empty space for the fourth graph. I d'like to place a legend in this space. legend() creates a legend in the last graph (the 3rd) I'd like a legend in the empty space. How may I do it? #graph parameter par( fin=c(6,6), #dim graph mai=c(1,1,0.5,0.5) #marges graph ,mfrow=c(2,2) ) #boxplots boxplot(x) title(main=expression(1- residuals distribution)) abline(0,0,lwd=2,col=2) boxplot(x) title(main=expression(2- residuals distribution)) abline(0,0,lwd=2,col=2) boxplot(x) title(main=expression(3- residuals distribution)) abline(0,0,lwd=2,col=2) Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Campus de Beaulieu, 263 Avenue du Général Leclerc 35700 Rennes, France Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc- rennes.fr/ [[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.
Re: [R] How to get estimate of confidence interval?
Hi, I don't know the fitdistr function, you may have a look on the function confint(). I use it after nls() to get the confidence interval of the assessed parameters. Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Ted Byers Envoyé : lundi 20 octobre 2008 18:50 À : r-help@r-project.org Objet : [R] How to get estimate of confidence interval? I thought I was finished, having gotten everything to work as intended. This is a model of risk, and the short term forecasts look very good, given the data collected after the estimates are produced (this model is intended to be executed daily, to give a continuing picture of our risk). But now there is a new requirement. I have weekly samples from a non-autonomous process (i.e. although well modelled as a decay process, with an exponential distribution fitting the decay times well, the rate estimates and their sd vary considerably from one week to the next). The total number of events to be expected from a given sample over the next week can be easily estimated from a simple integral. And the total number of these events from all samples, is just the sum of these estimates over all samples. So far, so good (imagine you have a sample of a variety of species of radionuclides all emitting alpha particles with the same energy - so you can't tell from the decay event which species produced the alpha particles). I guess there are two parts of my question. I get a fit of the exponential distribution to each sample using fitdistr(x,exponential). I am finding the expected values vary by as much as a factor of 4, and the corresponding estimates of sd vary by as much as a factor of 100 (some samples are MUCH larger than others). How do I go from the sd it gives to a 99% confidence interval for the integral for that function from now through a week from now (or to the end of time, or through the next month/quarter)? And how do I move from these estimates to get the expected value and confidence intervals for the totals over all the samples? I am a bit rusty on figuring out how error propagates through model calculations (an online reference for this would be handy, if you know of one). Thanks Ted -- View this message in context: http://www.nabble.com/How-to-get-estimate-of-confidence-interval--tp20073921 p20073921.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 and provide commented, minimal, self-contained, reproducible code. __ 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] create list of data frames
Hi all, I need to realize nonlinear regression on a thousand data sets. I guess the lapply function would help me on that thus I'd like to create a list of data frames, each data frame containing the data as follows: CeQe 1 1.849147 0.1958672 2 10.054250 0.5771036 3 18.077246 0.7718514 4 27.576468 0.8079606 5 35.146862 0.8500489 6 43.245078 0.8366673 7 51.745760 0.8879672 8 59.767086 0.8860329 The data are in arrays DATA1.x which contains Ce and DATA1.y which contains Qe as follows: .. [,988][,989][,990][,991][,992][,993][,994] [1,] 2.28584 1.464201 2.252296 2.050368 1.820814 1.460908 2.489860 [2,] 10.69722 10.060908 10.394847 10.305939 9.313467 10.600574 9.684784 [3,] 19.02983 19.025505 18.452735 18.764500 18.474322 18.906141 18.410527 [4,] 27.33536 27.083139 26.741224 26.943614 26.706248 26.86 27.268291 [5,] 34.86732 34.636166 35.185439 35.407979 34.849281 34.195723 34.669640 [6,] 42.67302 43.202754 43.179338 43.530424 43.861326 43.888251 42.663388 [7,] 51.51916 52.331856 50.661131 51.272102 51.938743 51.866432 50.892845 [8,] 60.73692 60.468978 60.582377 59.610627 60.857182 59.293317 59.654958 [,995][,996][,997][,998][,999] [,1000] [1,] 2.303937 2.959057 2.471204 2.089243 2.673633 1.849147 [2,] 10.687650 10.647979 9.720253 10.546309 10.144749 10.054250 [3,] 18.787858 19.015047 18.086981 18.854964 18.577910 18.077246 [4,] 27.248525 26.615157 27.876889 27.137564 26.607100 27.576468 [5,] 35.461289 34.686118 35.122716 34.873995 34.953602 35.146862 [6,] 43.915466 42.534826 43.264155 43.105342 42.877609 43.245078 [7,] 51.738493 52.289541 51.456639 52.464800 51.406434 51.745760 [8,] 59.549702 59.817789 59.471866 60.149036 60.411239 59.767086 To realize the data frame I've tried this for (i in 1:1000) { foo-list(c(foo[],data.frame(Ce=DATA1.x[,i],Qe=DATA1.y[,i]))) } but the program craches when I want to see foo. Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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.
Re: [R] create list of data frames
Hi Ken, Your command works fine and your comment was right as well, here is the final command (inspired from yours) directly on DATA1.x and DATA1.y foo3-list() for (i in 1:1000) foo3[[i]]-nls( Qe~LgmFla(a,b,Ce), data=list(Ce=DATA1.x[,i],Qe=DATA1.y[,i]), start=c(a=0.5,b=0.1) ) Thanks a lot :) Regards/Cordialement Benoit Boulinguiez _ De : Kenn Konstabel [mailto:[EMAIL PROTECTED] Envoyé : lundi 27 octobre 2008 16:59 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R] create list of data frames Hi, To realize the data frame I've tried this for (i in 1:1000) { foo-list(c(foo[],data.frame( Ce=DATA1.x[,i],Qe=DATA1.y[,i]))) } I think the following would do it: foo - list() for(i in 1:1000) foo[[i]] - data.frame(Ce = DATA1.x[,i], Qe=DATA1.y[,i]) But then again, do you really need a list of data frames? You can run your analyses directly on DATA1.xyz... Best regards, Kenn On Mon, Oct 27, 2008 at 5:44 PM, Benoit Boulinguiez [EMAIL PROTECTED] wrote: Hi all, I need to realize nonlinear regression on a thousand data sets. I guess the lapply function would help me on that thus I'd like to create a list of data frames, each data frame containing the data as follows: CeQe 1 1.849147 0.1958672 2 10.054250 0.5771036 3 18.077246 0.7718514 4 27.576468 0.8079606 5 35.146862 0.8500489 6 43.245078 0.8366673 7 51.745760 0.8879672 8 59.767086 0.8860329 The data are in arrays DATA1.x which contains Ce and DATA1.y which contains Qe as follows: .. [,988][,989][,990][,991][,992][,993][,994] [1,] 2.28584 1.464201 2.252296 2.050368 1.820814 1.460908 2.489860 [2,] 10.69722 10.060908 10.394847 10.305939 9.313467 10.600574 9.684784 [3,] 19.02983 19.025505 18.452735 18.764500 18.474322 18.906141 18.410527 [4,] 27.33536 27.083139 26.741224 26.943614 26.706248 26.86 27.268291 [5,] 34.86732 34.636166 35.185439 35.407979 34.849281 34.195723 34.669640 [6,] 42.67302 43.202754 43.179338 43.530424 43.861326 43.888251 42.663388 [7,] 51.51916 52.331856 50.661131 51.272102 51.938743 51.866432 50.892845 [8,] 60.73692 60.468978 60.582377 59.610627 60.857182 59.293317 59.654958 [,995][,996][,997][,998][,999] [,1000] [1,] 2.303937 2.959057 2.471204 2.089243 2.673633 1.849147 [2,] 10.687650 10.647979 9.720253 10.546309 10.144749 10.054250 [3,] 18.787858 19.015047 18.086981 18.854964 18.577910 18.077246 [4,] 27.248525 26.615157 27.876889 27.137564 26.607100 27.576468 [5,] 35.461289 34.686118 35.122716 34.873995 34.953602 35.146862 [6,] 43.915466 42.534826 43.264155 43.105342 42.877609 43.245078 [7,] 51.738493 52.289541 51.456639 52.464800 51.406434 51.745760 [8,] 59.549702 59.817789 59.471866 60.149036 60.411239 59.767086 To realize the data frame I've tried this for (i in 1:1000) { foo-list(c(foo[],data.frame(Ce=DATA1.x[,i],Qe=DATA1.y[,i]))) } but the program craches when I want to see foo. Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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. [[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.
[R] continue a loop after an error with confint
Hi all, I've got a list (Reg3Lst) with 1000 nls regression results in it. I'd like to get the confidence interval of the parameters obtained with the nonlinear regressions. Thus I've used this: for (i in 1:1000) { foo-list(foo,confint(Reg3Lst[[i]])) } For some regressions the confidence interval is not estimated because of a singular gradient result. Then it stops the loop. Is that possible to continue the loop after an error returned by confint? Regards/Cordialement - Benoit Boulinguiez Ph.D Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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.
[R] handle graph size in eps
Hi all, I've got a density graph made with the following commands: win.graph(width=13,height=6) par ( fin=c(13,3) ,mai=c(1,1,0.5,0.5) ,mfrow=c(1,2) ,cex.axis=1.5 ,cex.lab=1.5) dens-density(DATA1.y[2,]-mean(DATA1.y[2,]),kernel=gaussian) xlimit-range(dens$x) ylimit-range(dens$y) hist( DATA1.y[2,]-mean(DATA1.y[2,]) ,xlim=1.1*xlimit ,xlab=expression(q[e]) ,ylim=1.1*ylimit ,probability=T ,main=Random distribution around y) lines(dens,col=2,) rm(dens,xlimit,ylimit) qqnorm(DATA1.x[1,]) that's what I've on the screen and I'm OK with that. http://www.4shared.com/file/90283562/9f27d83b/screen.html When I save the graph in eps format I've got that http://www.4shared.com/file/90283115/490b7383/density_v_1.html what am I doing wrong? Regards Benoit __ 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] handle graph size in eps
Sorry for the lack of information. I'm indeed under Windows. I indeed used the menu save as in the graph window. The matter with the eps obtained was the width of the graph which is lower than what I had on the screen or what I got when I saved it as a JPEG file. I tried the postscript command postscript(test.eps,width=14,height=6) print.it=TRUE { #windows(width=6,height=6) par ( fin=c(6,6) ,mai=c(1,1,0.5,0.5) ,mfrow=c(1,2) ,cex.axis=1.5 ,cex.lab=1.5) dens-density(DATA1.y[2,]-mean(DATA1.y[2,]),kernel=gaussian) xlimit-range(dens$x) ylimit-range(dens$y) hist( DATA1.y[2,]-mean(DATA1.y[2,]) ,xlim=1.1*xlimit ,xlab=expression(q[e]) ,ylim=1.1*ylimit ,probability=T ,main=Random distribution around y) lines(dens,col=2,lwd=2) qqnorm(DATA1.x[1,]) } dev.off() rm(dens,xlimit,ylimit) I barely managed to get the ratio I want for the graph http://www.4shared.com/file/90339223/5a3239fc/test.html But still when I change the width in the poscript command from 12 to 20 for instance, it doesn't change anything... why? BTW how do I stop the pipe between a poscript file and R without closing R? Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Envoyé : lundi 2 mars 2009 11:25 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R] handle graph size in eps On Mon, 2 Mar 2009, Benoit Boulinguiez wrote: Hi all, I've got a density graph made with the following commands: win.graph(width=13,height=6) The preferred name is windows(). par ( fin=c(13,3) ,mai=c(1,1,0.5,0.5) ,mfrow=c(1,2) ,cex.axis=1.5 ,cex.lab=1.5) dens-density(DATA1.y[2,]-mean(DATA1.y[2,]),kernel=gaussian) xlimit-range(dens$x) ylimit-range(dens$y) hist( DATA1.y[2,]-mean(DATA1.y[2,]) ,xlim=1.1*xlimit ,xlab=expression(q[e]) ,ylim=1.1*ylimit ,probability=T ,main=Random distribution around y) lines(dens,col=2,) rm(dens,xlimit,ylimit) qqnorm(DATA1.x[1,]) that's what I've on the screen and I'm OK with that. http://www.4shared.com/file/90283562/9f27d83b/screen.html When I save the graph in eps format How exactly? I know at least three ways to do that. I am guessing that as you didn't tell us you were on Windows, you also didn't tell us that you used the menu on the windows() device, but these details do matter. I've got that http://www.4shared.com/file/90283115/490b7383/density_v_1.html what am I doing wrong? Not telling us what you don't like about this plot. I think you should consider using dev.copy2eps(), which will give you more control. Or even better, calling postscript() directly. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] ggplot2: geom_smooth and legend
Sorry I forgot the code that goes with **CODE desorb_plot-ggplot() + geom_smooth(data=DATA.B1_SA_N2, aes(Temp,DrTGA*100,colour=B1),span=0.1,size=1.6) + geom_smooth(data=DATA.FM30K_SA_N2, aes(Temp,DrTGA*100,colour=FM30K),span=0.2,size=1.6) + geom_smooth(data=DATA.NC60_SA_N2, aes(Temp,-DrTGA*100,colour=NC60),span=0.1,size=1.6) + geom_smooth(data=DATA.THC515_SA_N2, aes(Temp,DrTGA*100,colour=THC515),span=0.2,size=1.6) + scale_colour_hue(name=Adsorbent) + labs(x=Temp~(degree*C),y=Weight~Derivative~(%/*degree*C)) + opts(panel.grid.minor = theme_line(colour = grey94)) print(desorb_plot) Cordialement / Regards --- Benoit Boulinguiez Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ Quoting Benoit Boulinguiez benoit.boulingu...@ensc-rennes.fr: Hi all, Is that possible to remove the grey colour in the legend key that goes with the geom_smooth? In my case it doesn't ease the reading of the legend. http://www.4shared.com/file/125864977/e10644f8/desorb.html Cordialement / Regards --- Benoit Boulinguiez Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ __ 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] ggplot2: geom_smooth and legend
Hi! simple word thank you Hadley! an answer bringing a new question... is that possible to mix the colour and linetype representation with geom_smooth()? I tried the following code, though it hasn't worked. I have three different datasets due to non even x-axis (Temp) values I guess I should handle the matter from this point...no? CODE # air_N2_desorb_plot-ggplot() + geom_smooth(data=DATA.NC60_N2_v1, aes(Temp,-DrTGA*100,colour=N2_v1),span=0.05,size=1.6,se=F) + geom_smooth(data=DATA.NC60_N2_v2, aes(Temp,-DrTGA*100,colour=N2_v2),span=0.05,size=1.6,se=F) + geom_smooth(data=DATA.NC60_air_v1, aes(Temp,-DrTGA*100,colour=Air_v1),span=0.05,size=1.6,se=F) + geom_smooth(data=DATA.NC60_N2_v1, aes(Temp,-DrTGA*100,linetype=N2_v1),span=0.05,size=1.6,se=F) + geom_smooth(data=DATA.NC60_N2_v2, aes(Temp,-DrTGA*100,linetype=N2_v2),span=0.05,size=1.6,se=F) + geom_smooth(data=DATA.NC60_air_v1, aes(Temp,-DrTGA*100,linetype=Air_v1),span=0.05,size=1.6,se=F) + scale_colour_hue(name=Desorption\n Condition) + labs(x=Temp~(degree*C),y=Weight~Derivative~(%/*degree*C)) + opts(panel.grid.minor = theme_line(colour = grey94)) print(air_N2_desorb_plot) Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : hadley wickham [mailto:h.wick...@gmail.com] Envoyé : mercredi 26 août 2009 19:58 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R] ggplot2: geom_smooth and legend Hi Benoit, You could turn the standard errors off with se = F. Then they'll be removed from the legend as well. Hadley On Tue, Aug 18, 2009 at 7:43 AM, Benoit Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote: Sorry I forgot the code that goes with **CODE desorb_plot-ggplot() + geom_smooth(data=DATA.B1_SA_N2, aes(Temp,DrTGA*100,colour=B1),span=0.1,size=1.6) + geom_smooth(data=DATA.FM30K_SA_N2, aes(Temp,DrTGA*100,colour=FM30K),span=0.2,size=1.6) + geom_smooth(data=DATA.NC60_SA_N2, aes(Temp,-DrTGA*100,colour=NC60),span=0.1,size=1.6) + geom_smooth(data=DATA.THC515_SA_N2, aes(Temp,DrTGA*100,colour=THC515),span=0.2,size=1.6) + scale_colour_hue(name=Adsorbent) + labs(x=Temp~(degree*C),y=Weight~Derivative~(%/*degree*C)) + opts(panel.grid.minor = theme_line(colour = grey94)) print(desorb_plot) Cordialement / Regards --- Benoit Boulinguiez Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ Quoting Benoit Boulinguiez benoit.boulingu...@ensc-rennes.fr: Hi all, Is that possible to remove the grey colour in the legend key that goes with the geom_smooth? In my case it doesn't ease the reading of the legend. http://www.4shared.com/file/125864977/e10644f8/desorb.html Cordialement / Regards --- Benoit Boulinguiez Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ __ 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. -- http://had.co.nz/ __ 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] ggplot2: geom_smooth and legend
I cleared out the data frame, I have now one data frame with all the values in as a function of the experimental condition. + successfully mix the linestyle and colour_hue representation of the geom_smooth though it doesn't look good NEW CODE air_N2_desorb_plot-ggplot(DATA,aes(Temp,-DrTGA*100,colour=Cond)) + geom_smooth(span=0.05,size=1.6,se=F,alpha=0.8) + geom_smooth(aes(linetype=Cond),span=0.05,size=1.6,se=F) + scale_colour_hue(name=Desorption\n Condition) + scale_linetype(name=Desorption\n Condition) + labs(x=Temp~(degree*C),y=Weight~Derivative~(%/*degree*C)) + opts(panel.grid.minor = theme_line(colour = grey94)) print(air_N2_desorb_plot) Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] De la part de Benoit Boulinguiez Envoyé : mardi 1 septembre 2009 17:20 À : r-help@r-project.org Objet : Re: [R] ggplot2: geom_smooth and legend Hi! simple word thank you Hadley! an answer bringing a new question... is that possible to mix the colour and linetype representation with geom_smooth()? I tried the following code, though it hasn't worked. I have three different datasets due to non even x-axis (Temp) values I guess I should handle the matter from this point...no? CODE # air_N2_desorb_plot-ggplot() + geom_smooth(data=DATA.NC60_N2_v1, aes(Temp,-DrTGA*100,colour=N2_v1),span=0.05,size=1.6,se=F) + geom_smooth(data=DATA.NC60_N2_v2, aes(Temp,-DrTGA*100,colour=N2_v2),span=0.05,size=1.6,se=F) + geom_smooth(data=DATA.NC60_air_v1, aes(Temp,-DrTGA*100,colour=Air_v1),span=0.05,size=1.6,se=F) + geom_smooth(data=DATA.NC60_N2_v1, aes(Temp,-DrTGA*100,linetype=N2_v1),span=0.05,size=1.6,se=F) + geom_smooth(data=DATA.NC60_N2_v2, aes(Temp,-DrTGA*100,linetype=N2_v2),span=0.05,size=1.6,se=F) + geom_smooth(data=DATA.NC60_air_v1, aes(Temp,-DrTGA*100,linetype=Air_v1),span=0.05,size=1.6,se=F) + scale_colour_hue(name=Desorption\n Condition) + labs(x=Temp~(degree*C),y=Weight~Derivative~(%/*degree*C)) + opts(panel.grid.minor = theme_line(colour = grey94)) print(air_N2_desorb_plot) Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : hadley wickham [mailto:h.wick...@gmail.com] Envoyé : mercredi 26 août 2009 19:58 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R] ggplot2: geom_smooth and legend Hi Benoit, You could turn the standard errors off with se = F. Then they'll be removed from the legend as well. Hadley On Tue, Aug 18, 2009 at 7:43 AM, Benoit Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote: Sorry I forgot the code that goes with **CODE desorb_plot-ggplot() + geom_smooth(data=DATA.B1_SA_N2, aes(Temp,DrTGA*100,colour=B1),span=0.1,size=1.6) + geom_smooth(data=DATA.FM30K_SA_N2, aes(Temp,DrTGA*100,colour=FM30K),span=0.2,size=1.6) + geom_smooth(data=DATA.NC60_SA_N2, aes(Temp,-DrTGA*100,colour=NC60),span=0.1,size=1.6) + geom_smooth(data=DATA.THC515_SA_N2, aes(Temp,DrTGA*100,colour=THC515),span=0.2,size=1.6) + scale_colour_hue(name=Adsorbent) + labs(x=Temp~(degree*C),y=Weight~Derivative~(%/*degree*C)) + opts(panel.grid.minor = theme_line(colour = grey94)) print(desorb_plot) Cordialement / Regards --- Benoit Boulinguiez Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ Quoting Benoit Boulinguiez benoit.boulingu...@ensc-rennes.fr: Hi all, Is that possible to remove the grey colour in the legend key that goes with the geom_smooth? In my case it doesn't ease the reading of the legend. http://www.4shared.com/file/125864977/e10644f8/desorb.html Cordialement / Regards --- Benoit Boulinguiez Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ __ 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. -- http://had.co.nz/ __ 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
[R] ggplot2: mixing colour and linetype in geom_line
Hi all, I try to represent a multiple curve graphic where the x-axis is the temperature and the different y-axes are the different X (X22,X43,X44...) some X corresponds to the same molecule (22 and 44 are for CO2 for instance) so I use the same colour for them. I wanna mix the linetype with the colour to be able to visually see the difference between X43 and X45 The best I have done up to now is this code but it crashes with :Error in col2rgb(colour, TRUE) : invalid color name 'AA' if I skip the linetype in geom it works perfectly of course THT_N2_ATGMS_plot-ggplot(THT_N2_ATGMS,aes(x=Temp)) + # geom_line(aes(y=X22,colour=CO2)) + # geom_line(aes(y=X44,colour=CO2)) + geom_line(aes(y=X43,colour=AA,linetype=43)) + geom_line(aes(y=X45,colour=AA,linetype=45)) data set looks like: Temp X22 X43 X44 X45 X48 X58 X60 125.97650 4.62e-12 6.14e-11 3.93e-10 1.29e-11 2.05e-10 6.78e-12 9.31e-12 226.57025 4.73e-12 6.11e-11 3.91e-10 1.28e-11 2.05e-10 6.80e-12 9.43e-12 327.16400 4.62e-12 6.04e-11 3.91e-10 1.27e-11 2.05e-10 6.87e-12 9.28e-12 427.75650 4.57e-12 6.06e-11 3.90e-10 1.27e-11 2.03e-10 6.79e-12 9.26e-12 528.34892 4.64e-12 6.01e-11 3.89e-10 1.28e-11 2.03e-10 6.75e-12 9.18e-12 628.94142 4.71e-12 6.01e-11 3.88e-10 1.27e-11 2.02e-10 6.67e-12 9.24e-12 729.53125 4.70e-12 5.93e-11 3.87e-10 1.27e-11 2.02e-10 6.65e-12 9.20e-12 830.12233 4.64e-12 5.91e-11 3.86e-10 1.26e-11 2.01e-10 6.63e-12 9.11e-12 930.71483 4.71e-12 5.91e-11 3.85e-10 1.25e-11 2.01e-10 6.59e-12 9.17e-12 10 31.30983 4.51e-12 5.88e-11 3.85e-10 1.23e-11 2.00e-10 6.54e-12 9.00e-12 11 31.90233 4.52e-12 5.80e-11 3.85e-10 1.23e-11 1.99e-10 6.60e-12 9.09e-12 12 32.49475 4.47e-12 5.80e-11 3.83e-10 1.24e-11 1.99e-10 6.57e-12 8.95e-12 13 33.08458 4.58e-12 5.79e-11 3.83e-10 1.23e-11 1.98e-10 6.57e-12 9.02e-12 14 33.67575 4.56e-12 5.75e-11 3.82e-10 1.22e-11 1.97e-10 6.43e-12 8.89e-12 15 34.26558 4.53e-12 5.74e-11 3.80e-10 1.23e-11 1.97e-10 6.42e-12 8.97e-12 16 34.85933 4.54e-12 5.70e-11 3.80e-10 1.22e-11 1.96e-10 6.48e-12 8.93e-12 17 35.45183 4.55e-12 5.67e-11 3.79e-10 1.21e-11 1.96e-10 6.38e-12 8.86e-12 18 36.04683 4.54e-12 5.66e-11 3.78e-10 1.20e-11 1.95e-10 6.37e-12 8.90e-12 19 36.63933 4.53e-12 5.61e-11 3.77e-10 1.19e-11 1.94e-10 6.45e-12 8.85e-12 20 37.23042 4.50e-12 5.57e-11 3.77e-10 1.21e-11 1.94e-10 6.35e-12 8.82e-12 21 37.82417 4.55e-12 5.58e-11 3.76e-10 1.19e-11 1.94e-10 6.29e-12 8.86e-12 22 38.41400 4.57e-12 5.57e-11 3.75e-10 1.20e-11 1.92e-10 6.30e-12 8.80e-12 Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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.
Re: [R] ggplot2: mixing colour and linetype in geom_line
many thanks Felipe I didn't know the melt function. I'll have a close look at it. Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : Felipe Carrillo [mailto:mazatlanmex...@yahoo.com] Envoyé : mercredi 9 septembre 2009 20:40 À : r-help@r-project.org; Benoit Boulinguiez Objet : Re: [R] ggplot2: mixing colour and linetype in geom_line Is this what you want? x - structure(list(Temp = c(25.9765, 26.57025, 27.164, 27.7565, 28.34892, 28.94142, 29.53125, 30.12233, 30.71483, 31.30983, 31.90233, 32.49475, 33.08458, 33.67575, 34.26558, 34.85933, 35.45183, 36.04683, 36.63933, 37.23042, 37.82417, 38.414), X22 = c(4.62e-12, 4.73e-12, 4.62e-12, 4.57e-12, 4.64e-12, 4.71e-12, 4.7e-12, 4.64e-12, 4.71e-12, 4.51e-12, 4.52e-12, 4.47e-12, 4.58e-12, 4.56e-12, 4.53e-12, 4.54e-12, 4.55e-12, 4.54e-12, 4.53e-12, 4.5e-12, 4.55e-12, 4.57e-12), X43 = c(6.14e-11, 6.11e-11, 6.04e-11, 6.06e-11, 6.01e-11, 6.01e-11, 5.93e-11, 5.91e-11, 5.91e-11, 5.88e-11, 5.8e-11, 5.8e-11, 5.79e-11, 5.75e-11, 5.74e-11, 5.7e-11, 5.67e-11, 5.66e-11, 5.61e-11, 5.57e-11, 5.58e-11, 5.57e-11 ), X44 = c(3.93e-10, 3.91e-10, 3.91e-10, 3.9e-10, 3.89e-10, 3.88e-10, 3.87e-10, 3.86e-10, 3.85e-10, 3.85e-10, 3.85e-10, 3.83e-10, 3.83e-10, 3.82e-10, 3.8e-10, 3.8e-10, 3.79e-10, 3.78e-10, 3.77e-10, 3.77e-10, 3.76e-10, 3.75e-10), X45 = c(1.29e-11, 1.28e-11, 1.27e-11, 1.27e-11, 1.28e-11, 1.27e-11, 1.27e-11, 1.26e-11, 1.25e-11, 1.23e-11, 1.23e-11, 1.24e-11, 1.23e-11, 1.22e-11, 1.23e-11, 1.22e-11, 1.21e-11, 1.2e-11, 1.19e-11, 1.21e-11, 1.19e-11, 1.2e-11), X48 = c(2.05e-10, 2.05e-10, 2.05e-10, 2.03e-10, 2.03e-10, 2.02e-10, 2.02e-10, 2.01e-10, 2.01e-10, 2e-10, 1.99e-10, 1.99e-10, 1.98e-10, 1.97e-10, 1.97e-10, 1.96e-10, 1.96e-10, 1.95e-10, 1.94e-10, 1.94e-10, 1.94e-10, 1.92e-10), X58 = c(6.78e-12, 6.8e-12, 6.87e-12, 6.79e-12, 6.75e-12, 6.67e-12, 6.65e-12, 6.63e-12, 6.59e-12, 6.54e-12, 6.6e-12, 6.57e-12, 6.57e-12, 6.43e-12, 6.42e-12, 6.48e-12, 6.38e-12, 6.37e-12, 6.45e-12, 6.35e-12, 6.29e-12, 6.3e-12), X60 = c(9.31e-12, 9.43e-12, 9.28e-12, 9.26e-12, 9.18e-12, 9.24e-12, 9.2e-12, 9.11e-12, 9.17e-12, 9e-12, 9.09e-12, 8.95e-12, 9.02e-12, 8.89e-12, 8.97e-12, 8.93e-12, 8.86e-12, 8.9e-12, 8.85e-12, 8.82e-12, 8.86e-12, 8.8e-12)), .Names = c(Temp, X22, X43, X44, X45, X48, X58, X60), class = data.frame, row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)) attach(x) xmelt - melt(x,id.vars=Temp);head(xmelt) qplot(Temp,value,colour=variable,linetype=variable,data=xmelt,geom=line) Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA --- On Wed, 9/9/09, Benoit Boulinguiez benoit.boulingu...@ensc-rennes.fr wrote: From: Benoit Boulinguiez benoit.boulingu...@ensc-rennes.fr Subject: [R] ggplot2: mixing colour and linetype in geom_line To: r-help@r-project.org Date: Wednesday, September 9, 2009, 8:24 AM Hi all, I try to represent a multiple curve graphic where the x-axis is the temperature and the different y-axes are the different X (X22,X43,X44...) some X corresponds to the same molecule (22 and 44 are for CO2 for instance) so I use the same colour for them. I wanna mix the linetype with the colour to be able to visually see the difference between X43 and X45 The best I have done up to now is this code but it crashes with :Error in col2rgb(colour, TRUE) : invalid color name 'AA' if I skip the linetype in geom it works perfectly of course THT_N2_ATGMS_plot-ggplot(THT_N2_ATGMS,aes(x=Temp)) + # geom_line(aes(y=X22,colour=CO2)) + # geom_line(aes(y=X44,colour=CO2)) + geom_line(aes(y=X43,colour=AA,linetype=43)) + geom_line(aes(y=X45,colour=AA,linetype=45)) data set looks like: Temp X22 X43 X44 X45 X48 X58 X60 1 25.97650 4.62e-12 6.14e-11 3.93e-10 1.29e-11 2.05e-10 6.78e-12 9.31e-12 2 26.57025 4.73e-12 6.11e-11 3.91e-10 1.28e-11 2.05e-10 6.80e-12 9.43e-12 3 27.16400 4.62e-12 6.04e-11 3.91e-10 1.27e-11 2.05e-10 6.87e-12 9.28e-12 4 27.75650 4.57e-12 6.06e-11 3.90e-10 1.27e-11 2.03e-10 6.79e-12 9.26e-12 5 28.34892 4.64e-12 6.01e-11 3.89e-10 1.28e-11 2.03e-10 6.75e-12 9.18e-12 6 28.94142 4.71e-12 6.01e-11 3.88e-10 1.27e-11 2.02e-10 6.67e-12 9.24e-12 7 29.53125 4.70e-12 5.93e-11 3.87e-10 1.27e-11 2.02e-10 6.65e-12 9.20e-12 8 30.12233 4.64e-12 5.91e-11 3.86e-10 1.26e-11 2.01e-10 6.63e-12 9.11e-12 9 30.71483 4.71e-12 5.91e-11 3.85e-10 1.25e-11 2.01e-10 6.59e-12 9.17e-12 10 31.30983 4.51e-12 5.88e-11 3.85e-10 1.23e-11 2.00e-10 6.54e-12 9.00e-12 11 31.90233 4.52e-12 5.80e-11 3.85e-10 1.23e-11 1.99e-10 6.60e-12 9.09e-12 12 32.49475 4.47e-12 5.80e-11 3.83e-10 1.24e-11 1.99e-10 6.57e-12 8.95e-12 13 33.08458 4.58e-12 5.79e-11 3.83e-10 1.23e-11 1.98e-10 6.57e-12 9.02e-12 14 33.67575 4.56e-12 5.75e-11 3.82e-10 1.22e-11 1.97e-10 6.43e-12 8.89e-12 15 34.26558 4.53e-12
[R] grid lines aligned on each ticks with a log scale
Hi all, for publication purpose I must provide a graph with grid lines aligned with each tick mark. Thing is that the graph has a log scale on the x-axis. I looked at the grid() and par() documentation but still don't figure out how to get it done. simple example plot(seq(1,9), log=x, panel.first=grid()) how to get lines at x = 2 and 5 on the graph? Of course the option nx in grid() is not valid, as it does not align the grid lines with the ticks in a log scale... Thanks for giving a hand. Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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.
Re: [R] grid lines aligned on each ticks with a log scale
Terrific! How could I've missed that. Well, I know, I didn't get it from the documentation... Thanks Regards/Cordialement Benoit Boulinguiez -Message d'origine- De : Duncan Murdoch [mailto:murd...@stats.uwo.ca] Envoyé : samedi 20 mars 2010 14:54 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R] grid lines aligned on each ticks with a log scale On 20/03/2010 7:35 AM, Duncan Murdoch wrote: On 20/03/2010 6:38 AM, Benoit Boulinguiez wrote: Hi all, for publication purpose I must provide a graph with grid lines aligned with each tick mark. Thing is that the graph has a log scale on the x-axis. I looked at the grid() and par() documentation but still don't figure out how to get it done. simple example plot(seq(1,9), log=x, panel.first=grid()) how to get lines at x = 2 and 5 on the graph? Use abline instead of grid for fine tuning: plot(seq(1,9), log=x, panel.first=abline(v=c(1,2,5),h=c(2,4,6,8), lty=3,col=gray)) or more simply, just use equilogs=FALSE in the grid call: plot(seq(1,9), log=x, panel.first=grid(equilogs=FALSE)) Duncan Murdoch Duncan Murdoch Of course the option nx in grid() is not valid, as it does not align the grid lines with the ticks in a log scale... Thanks for giving a hand. Regards/Cordialement - Benoit Boulinguiez Ph.D student Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 Sciences Chimiques de Rennes Avenue du Général Leclerc CS 50837 35708 Rennes CEDEX 7 Tel 33 (0)2 23 23 80 83 Fax 33 (0)2 23 23 81 20 http://www.ensc-rennes.fr/ http://www.ensc-rennes.fr/ [[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. __ 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-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.