Re: [R] [FORGED] Re: draw stripes in a circle in R
On 15/06/17 13:51, David Winsemius wrote: On Jun 14, 2017, at 5:52 PM, Jeff Newmillerwrote: Sigh. I never load packages in .Rprofile to avoid the irreproducibility trap. Might seem drastic to some, but I don't feel much pain because I almost always edit my code in a file rather than on the fly at the console, and re-run it frequently from a fresh R process to check my progress. Yes, . But I am a long-time user of the rms/Hmisc combo, as well as the survival package, so near the top of my .Rprofile is: require(lattice) require(sos) require(rms) Should I be ashamed of that? I suppose I should, and I _am_ ashamed of some of the other stuff in there , ... and I've been meaning to address my manifold deficiencies w.r.t. irreproducibility by moving to RStudio, but I keep putting it off. This is getting *way* off topic ... but why does using RStudio help with the irreproducibility problem? I thought that RStudio just made it easier to point-and-click. For those who like doing that sort of thing. (I tend to believe the dictum that a GUI makes it easy to do easy things and impossible to do hard things.) cheers, Rolf -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R-es] Regresión ponderada
Estimado Freddy Esa parte me gusta de nlme vs lme4, no se en cuánto es técnicamente fundamentado a mi gusto o es solo una subjetividad desde mi desconocimiento al no venir de una carrera estadística o matemática. Javier Rubén Marcuzzi De: Freddy Omar López Quintero Enviado: miércoles, 14 de junio de 2017 22:01 Para: Gerardo Gold CC: Lista R Asunto: Re: [R-es] Regresión ponderada 2017-06-14 15:35 GMT-04:00 Gerardo Gold: > Para el caso de datos agrupados, donde ya se tiene la desviación estándar o > varianza calculada ajustar un modelo ponderado es fácil, pero no se como > hacerlo con datos sin agrupar. > Si no entiendo mal, el núcleo del problema son las varianzas de la relación. Una opción sería incluir entonces una estructura para la varianza. Tomando arbitrariamente el conjunto de datos swiss como ejemplo, podría ser algo como: library(nlme) > gls(Fertility~Education, data=swiss, weights=varIdent(form=~1|Education)) y/o con el argumento correlation de la misma función. Quizás sirva. ¡Salud! -- «Pídeles sus títulos a los que te persiguen, pregúntales cuándo nacieron, diles que te demuestren su existencia.» Rafael Cadenas [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R] [FORGED] Re: draw stripes in a circle in R
> On Jun 14, 2017, at 5:52 PM, Jeff Newmillerwrote: > > Sigh. I never load packages in .Rprofile to avoid the irreproducibility trap. > Might seem drastic to some, but I don't feel much pain because I almost > always edit my code in a file rather than on the fly at the console, and > re-run it frequently from a fresh R process to check my progress. Yes, . But I am a long-time user of the rms/Hmisc combo, as well as the survival package, so near the top of my .Rprofile is: require(lattice) require(sos) require(rms) Should I be ashamed of that? I suppose I should, and I _am_ ashamed of some of the other stuff in there , ... and I've been meaning to address my manifold deficiencies w.r.t. irreproducibility by moving to RStudio, but I keep putting it off. -- David. > -- > Sent from my phone. Please excuse my brevity. > > On June 14, 2017 3:27:15 PM PDT, David Winsemius > wrote: >> >>> On Jun 14, 2017, at 1:53 PM, Rolf Turner >> wrote: >>> >>> On 15/06/17 05:29, David Winsemius wrote: > On Jun 14, 2017, at 10:18 AM, David Winsemius >> wrote: > > >> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller >> wrote: >> >> I don't see a question. If your question is whether R supports >> pattern fills, AFAIK it does not. If that is not your question, ask >> one. >> -- >> Sent from my phone. Please excuse my brevity. >> >> On June 14, 2017 7:57:41 AM PDT, jean-philippe >> wrote: >>> dear R users, >>> >>> I would like to fill a circle with yellow stripes instead of a >> uniform >>> yellow color. To draw the circle I used the following command >> after >>> having loaded the (very nice !) plotrix library : I finally understood the question and it needs a hack to the >> draw.circle function in plotrix since the angle and density arguments >> don't get passed in: First get code for draw.circle: -- draw.circle # then copy to console and edit draw.circle2 <- function (x, y, radius, nv = 100, border = NULL, >> col = NA, lty = 1, density=NA, angle=45, lwd = 1 ) { xylim <- par("usr") plotdim <- par("pin") ymult <- getYmult() angle.inc <- 2 * pi/nv angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) if (length(col) < length(radius)) col <- rep(col, length.out = length(radius)) for (circle in 1:length(radius)) { xv <- cos(angles) * radius[circle] + x yv <- sin(angles) * radius[circle] * ymult + y polygon(xv, yv, border = border, col = col, lty = lty, >> density=density, angle=angle, lwd = lwd) } invisible(list(x = xv, y = yv)) } Now run your call to pdf with draw.circle2 instead of draw.circle. >>> >>> This is just idle curiosity, since I'm not really able to contribute >> anything useful, but I can't resist asking: When I try to run the OP's >> code I get an error: >>> Error in alpha("red", 0.4) : could not find function "alpha". >>> >>> Why does this (apparently) not happen to anyone else? Why does the >> universe pick on *me*? What is the function "alpha()"? Where is it to >> be found? >> >> I discovered some time ago that I no longer needed to load the ggplot2 >> package. I wasn't entirely happy to make this discovery since I stilll >> cling to the old lattice style. Eventually I figgured out that it was >> because one of packages that I load in my .Rprofile-file had changed >> its imports. The `alpha` function I see is from ggplot2. Resistance is >> futile. I've now been partially assimilated. >> >> >>> >>> Searching on "alpha" is of course completely unproductive; there are >> far too many (totally irrelevant) instances. >> >> >>> >>> cheers, >>> >>> Rolf >>> >>> -- >>> Technical Editor ANZJS >>> Department of Statistics >>> University of Auckland >>> Phone: +64-9-373-7599 ext. 88276 >> >> David Winsemius >> Alameda, CA, USA David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [FORGED] Re: draw stripes in a circle in R
Sigh. I never load packages in .Rprofile to avoid the irreproducibility trap. Might seem drastic to some, but I don't feel much pain because I almost always edit my code in a file rather than on the fly at the console, and re-run it frequently from a fresh R process to check my progress. -- Sent from my phone. Please excuse my brevity. On June 14, 2017 3:27:15 PM PDT, David Winsemiuswrote: > >> On Jun 14, 2017, at 1:53 PM, Rolf Turner >wrote: >> >> On 15/06/17 05:29, David Winsemius wrote: On Jun 14, 2017, at 10:18 AM, David Winsemius > wrote: > On Jun 14, 2017, at 9:46 AM, Jeff Newmiller > wrote: > > I don't see a question. If your question is whether R supports >pattern fills, AFAIK it does not. If that is not your question, ask >one. > -- > Sent from my phone. Please excuse my brevity. > > On June 14, 2017 7:57:41 AM PDT, jean-philippe > wrote: >> dear R users, >> >> I would like to fill a circle with yellow stripes instead of a >uniform >> yellow color. To draw the circle I used the following command >after >> having loaded the (very nice !) plotrix library : >>> I finally understood the question and it needs a hack to the >draw.circle function in plotrix since the angle and density arguments >don't get passed in: >>> First get code for draw.circle: >>> -- >>> draw.circle # then copy to console and edit >>> draw.circle2 <- function (x, y, radius, nv = 100, border = NULL, >col = NA, lty = 1, >>>density=NA, angle=45, lwd = 1 ) >>> { >>> xylim <- par("usr") >>> plotdim <- par("pin") >>> ymult <- getYmult() >>> angle.inc <- 2 * pi/nv >>> angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) >>> if (length(col) < length(radius)) >>> col <- rep(col, length.out = length(radius)) >>> for (circle in 1:length(radius)) { >>> xv <- cos(angles) * radius[circle] + x >>> yv <- sin(angles) * radius[circle] * ymult + y >>> polygon(xv, yv, border = border, col = col, lty = lty, >density=density, angle=angle, >>> lwd = lwd) >>> } >>> invisible(list(x = xv, y = yv)) >>> } >>> Now run your call to pdf with draw.circle2 instead of draw.circle. >> >> This is just idle curiosity, since I'm not really able to contribute >anything useful, but I can't resist asking: When I try to run the OP's >code I get an error: >> >>> Error in alpha("red", 0.4) : could not find function "alpha". >> >> Why does this (apparently) not happen to anyone else? Why does the >universe pick on *me*? What is the function "alpha()"? Where is it to >be found? > >I discovered some time ago that I no longer needed to load the ggplot2 >package. I wasn't entirely happy to make this discovery since I stilll >cling to the old lattice style. Eventually I figgured out that it was >because one of packages that I load in my .Rprofile-file had changed >its imports. The `alpha` function I see is from ggplot2. Resistance is >futile. I've now been partially assimilated. > > >> >> Searching on "alpha" is of course completely unproductive; there are >far too many (totally irrelevant) instances. > > >> >> cheers, >> >> Rolf >> >> -- >> Technical Editor ANZJS >> Department of Statistics >> University of Auckland >> Phone: +64-9-373-7599 ext. 88276 > >David Winsemius >Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [FORGED] Re: draw stripes in a circle in R
On 15/06/17 10:27, David Winsemius wrote: On Jun 14, 2017, at 1:53 PM, Rolf Turnerwrote: Why does this (apparently) not happen to anyone else? Why does the universe pick on *me*? What is the function "alpha()"? Where is it to be found? I discovered some time ago that I no longer needed to load the ggplot2 package. I wasn't entirely happy to make this discovery since I stilll cling to the old lattice style. Eventually I figgured out that it was because one of packages that I load in my .Rprofile-file had changed its imports. The `alpha` function I see is from ggplot2. Resistance is futile. I've now been partially assimilated. N'ya-hah! The light dawns! Thank you. cheers, Rolf -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [FORGED] Re: about fitting a regression line
On 15/06/17 11:28, lily li wrote: Thanks. I thought lm() function is for linear model, such as the correlation below: Y= aX + b On Wed, Jun 14, 2017 at 5:25 PM, MacQueen, Donwrote: Start with the lm() function; i.e., see ?lm And you don't think that Y = a*cos(X) + b is a linear model? The mind boggles. Well, I guess there is a "subtlety" here. Linear models are *linear in the PARAMETERS of the model*, not in the predictors. First-year knuckle-draggers get confused about this. People who are using R to do research should be a bit beyond such confusion. cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [FORGED] about fitting a regression line
On 15/06/17 10:40, lily li wrote: Hi R users, I have some data points (Xi, Yi), and they may follow such a pattern Yi = cCOS(Xi) + d, how to find the c and d in R? which function to use? Also, how to get the R2 and p value for this correlation? Thanks for any kind of help. If I understand you correctly (always a dubious conditional): fit <- lm(y ~ cos(x)) where y and x are vectors of the y and x values of your data points, should answer all of your questions. I am bewildered that you need to ask. You have been posting to this list for quite a while. Have you learned nothing about R? It's time that you did. Read and study carefully "An Introduction to R" from the R web site -> Manuals. cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] about fitting a regression line
Thanks. I thought lm() function is for linear model, such as the correlation below: Y= aX + b On Wed, Jun 14, 2017 at 5:25 PM, MacQueen, Donwrote: > Start with the lm() function; i.e., see > > ?lm > > -Don > > -- > Don MacQueen > > Lawrence Livermore National Laboratory > 7000 East Ave., L-627 > Livermore, CA 94550 > 925-423-1062 > > > On 6/14/17, 3:40 PM, "R-help on behalf of lily li" < > r-help-boun...@r-project.org on behalf of chocol...@gmail.com> wrote: > > Hi R users, > > I have some data points (Xi, Yi), and they may follow such a pattern > Yi = > cCOS(Xi) + d, how to find the c and d in R? which function to use? > Also, > how to get the R2 and p value for this correlation? Thanks for any > kind of > help. > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] about fitting a regression line
Start with the lm() function; i.e., see ?lm -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/14/17, 3:40 PM, "R-help on behalf of lily li"wrote: Hi R users, I have some data points (Xi, Yi), and they may follow such a pattern Yi = cCOS(Xi) + d, how to find the c and d in R? which function to use? Also, how to get the R2 and p value for this correlation? Thanks for any kind of help. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [FORGED] Re: draw stripes in a circle in R
Package 'scales' has the alpha function... associated with ggplot2. A bit out of place here if that is the origin. Yes, we are squarely in non-reproducible example territory, also known as the Twilight Zone. -- Sent from my phone. Please excuse my brevity. On June 14, 2017 1:53:21 PM PDT, Rolf Turnerwrote: >On 15/06/17 05:29, David Winsemius wrote: >> >>> On Jun 14, 2017, at 10:18 AM, David Winsemius > wrote: >>> >>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller > wrote: I don't see a question. If your question is whether R supports >pattern fills, AFAIK it does not. If that is not your question, ask >one. -- Sent from my phone. Please excuse my brevity. On June 14, 2017 7:57:41 AM PDT, jean-philippe > wrote: > dear R users, > > I would like to fill a circle with yellow stripes instead of a >uniform > yellow color. To draw the circle I used the following command >after > having loaded the (very nice !) plotrix library : >> >> I finally understood the question and it needs a hack to the >draw.circle function in plotrix since the angle and density arguments >don't get passed in: >> >> First get code for draw.circle: >> >> -- >> >> draw.circle # then copy to console and edit >> >> draw.circle2 <- function (x, y, radius, nv = 100, border = NULL, col >= NA, lty = 1, >> density=NA, angle=45, lwd = 1 ) >> { >> xylim <- par("usr") >> plotdim <- par("pin") >> ymult <- getYmult() >> angle.inc <- 2 * pi/nv >> angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) >> if (length(col) < length(radius)) >> col <- rep(col, length.out = length(radius)) >> for (circle in 1:length(radius)) { >> xv <- cos(angles) * radius[circle] + x >> yv <- sin(angles) * radius[circle] * ymult + y >> polygon(xv, yv, border = border, col = col, lty = lty, >density=density, angle=angle, >> lwd = lwd) >> } >> invisible(list(x = xv, y = yv)) >> } >> >> Now run your call to pdf with draw.circle2 instead of draw.circle. > >This is just idle curiosity, since I'm not really able to contribute >anything useful, but I can't resist asking: When I try to run the OP's > >code I get an error: > >> Error in alpha("red", 0.4) : could not find function "alpha". > >Why does this (apparently) not happen to anyone else? Why does the >universe pick on *me*? What is the function "alpha()"? Where is it to > >be found? > >Searching on "alpha" is of course completely unproductive; there are >far >too many (totally irrelevant) instances. > >cheers, > >Rolf __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] about fitting a regression line
Hi R users, I have some data points (Xi, Yi), and they may follow such a pattern Yi = cCOS(Xi) + d, how to find the c and d in R? which function to use? Also, how to get the R2 and p value for this correlation? Thanks for any kind of help. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [FORGED] Re: draw stripes in a circle in R
> On Jun 14, 2017, at 1:53 PM, Rolf Turnerwrote: > > On 15/06/17 05:29, David Winsemius wrote: >>> On Jun 14, 2017, at 10:18 AM, David Winsemius >>> wrote: >>> >>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller wrote: I don't see a question. If your question is whether R supports pattern fills, AFAIK it does not. If that is not your question, ask one. -- Sent from my phone. Please excuse my brevity. On June 14, 2017 7:57:41 AM PDT, jean-philippe wrote: > dear R users, > > I would like to fill a circle with yellow stripes instead of a uniform > yellow color. To draw the circle I used the following command after > having loaded the (very nice !) plotrix library : >> I finally understood the question and it needs a hack to the draw.circle >> function in plotrix since the angle and density arguments don't get passed >> in: >> First get code for draw.circle: >> -- >> draw.circle # then copy to console and edit >> draw.circle2 <- function (x, y, radius, nv = 100, border = NULL, col = NA, >> lty = 1, >>density=NA, angle=45, lwd = 1 ) >> { >> xylim <- par("usr") >> plotdim <- par("pin") >> ymult <- getYmult() >> angle.inc <- 2 * pi/nv >> angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) >> if (length(col) < length(radius)) >> col <- rep(col, length.out = length(radius)) >> for (circle in 1:length(radius)) { >> xv <- cos(angles) * radius[circle] + x >> yv <- sin(angles) * radius[circle] * ymult + y >> polygon(xv, yv, border = border, col = col, lty = lty, >> density=density, angle=angle, >> lwd = lwd) >> } >> invisible(list(x = xv, y = yv)) >> } >> Now run your call to pdf with draw.circle2 instead of draw.circle. > > This is just idle curiosity, since I'm not really able to contribute anything > useful, but I can't resist asking: When I try to run the OP's code I get an > error: > >> Error in alpha("red", 0.4) : could not find function "alpha". > > Why does this (apparently) not happen to anyone else? Why does the universe > pick on *me*? What is the function "alpha()"? Where is it to be found? I discovered some time ago that I no longer needed to load the ggplot2 package. I wasn't entirely happy to make this discovery since I stilll cling to the old lattice style. Eventually I figgured out that it was because one of packages that I load in my .Rprofile-file had changed its imports. The `alpha` function I see is from ggplot2. Resistance is futile. I've now been partially assimilated. > > Searching on "alpha" is of course completely unproductive; there are far too > many (totally irrelevant) instances. > > cheers, > > Rolf > > -- > Technical Editor ANZJS > Department of Statistics > University of Auckland > Phone: +64-9-373-7599 ext. 88276 David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [FORGED] Re: draw stripes in a circle in R
Hi Jean-Phillipe, Thanks for the plug on plotrix. Because of that I will suggest a gross hack that will do almost what you want: # your code down to draw.circle segments(c(-12.7,-12.7),c(-11.2,-10.6),c(-12,-12), c(-10.75,-10.15),col="white",lwd=28) draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL, col=NA,lty=1,lwd=1) box() dev.off() Your problem is that plotrix is written in base graphics, which is simple to understand, but does not support layered graphics. Thus I have to do the striping over the yellow circle and avoid overwriting the big red stripe. You should do this using the grid graphic system, but that would take too large a chunk of my morning to write an example for you. To Rolf - It happened to me as well, but because I saw Venus smiling at me in the sky this morning I was granted the knowledge that it was a function that had not been properly introduced to us and simply replaced it with "red". Such are the benefits of evidence-based astrology. Jim On Thu, Jun 15, 2017 at 8:04 AM, jeanphilippe.fontainewrote: > > > > > > > Envoyé depuis mon appareil Samsung > > Message d'origine > De : Rolf Turner > Date : 14/06/2017 22:53 (GMT+01:00) > À : David Winsemius > Cc : r-help@r-project.org > Objet : Re: [R] [FORGED] Re: draw stripes in a circle in R > > On 15/06/17 05:29, David Winsemius wrote: >> >>> On Jun 14, 2017, at 10:18 AM, David Winsemius >>> wrote: >>> >>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller wrote: I don't see a question. If your question is whether R supports pattern fills, AFAIK it does not. If that is not your question, ask one. -- Sent from my phone. Please excuse my brevity. On June 14, 2017 7:57:41 AM PDT, jean-philippe wrote: > dear R users, > > I would like to fill a circle with yellow stripes instead of a uniform > yellow color. To draw the circle I used the following command after > having loaded the (very nice !) plotrix library : >> >> I finally understood the question and it needs a hack to the draw.circle >> function in plotrix since the angle and density arguments don't get passed >> in: >> >> First get code for draw.circle: >> >> -- >> >> draw.circle # then copy to console and edit >> >> draw.circle2 <- function (x, y, radius, nv = 100, border = NULL, col = NA, >> lty = 1, >> density=NA, angle=45, lwd = 1 ) >> { >> xylim <- par("usr") >> plotdim <- par("pin") >> ymult <- getYmult() >> angle.inc <- 2 * pi/nv >> angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) >> if (length(col) < length(radius)) >> col <- rep(col, length.out = length(radius)) >> for (circle in 1:length(radius)) { >> xv <- cos(angles) * radius[circle] + x >> yv <- sin(angles) * radius[circle] * ymult + y >> polygon(xv, yv, border = border, col = col, lty = lty, >> density=density, angle=angle, >> lwd = lwd) >> } >> invisible(list(x = xv, y = yv)) >> } >> >> Now run your call to pdf with draw.circle2 instead of draw.circle. > > This is just idle curiosity, since I'm not really able to contribute > anything useful, but I can't resist asking: When I try to run the OP's > code I get an error: > >> Error in alpha("red", 0.4) : could not find function "alpha". > > Sorry for the lack of precision, alpha is just to add some transparency to > the color. This alpha parameter ranges from 0 fully transparent to 1, full > color.I don't remember having loaded any package to use this function, I > think it is there in base R. > Why does this (apparently) not happen to anyone else? Why does the > universe pick on *me*? What is the function "alpha()"? Where is it to > be found? > > Searching on "alpha" is of course completely unproductive; there are far > too many (totally irrelevant) instances. > > cheers, > > Rolf > > -- > Technical Editor ANZJS > Department of Statistics > University of Auckland > Phone: +64-9-373-7599 ext. 88276 > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and
Re: [R] [FORGED] Re: draw stripes in a circle in R
Envoyé depuis mon appareil Samsung Message d'origine De : Rolf TurnerDate : 14/06/2017 22:53 (GMT+01:00) À : David Winsemius Cc : r-help@r-project.org Objet : Re: [R] [FORGED] Re: draw stripes in a circle in R On 15/06/17 05:29, David Winsemius wrote: > >> On Jun 14, 2017, at 10:18 AM, David Winsemius wrote: >> >> >>> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller >>> wrote: >>> >>> I don't see a question. If your question is whether R supports pattern >>> fills, AFAIK it does not. If that is not your question, ask one. >>> -- >>> Sent from my phone. Please excuse my brevity. >>> >>> On June 14, 2017 7:57:41 AM PDT, jean-philippe >>> wrote: dear R users, I would like to fill a circle with yellow stripes instead of a uniform yellow color. To draw the circle I used the following command after having loaded the (very nice !) plotrix library : > > I finally understood the question and it needs a hack to the draw.circle > function in plotrix since the angle and density arguments don't get passed in: > > First get code for draw.circle: > > -- > > draw.circle # then copy to console and edit > > draw.circle2 <- function (x, y, radius, nv = 100, border = NULL, col = NA, > lty = 1, > density=NA, angle=45, lwd = 1 ) > { > xylim <- par("usr") > plotdim <- par("pin") > ymult <- getYmult() > angle.inc <- 2 * pi/nv > angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) > if (length(col) < length(radius)) > col <- rep(col, length.out = length(radius)) > for (circle in 1:length(radius)) { > xv <- cos(angles) * radius[circle] + x > yv <- sin(angles) * radius[circle] * ymult + y > polygon(xv, yv, border = border, col = col, lty = lty, >density=density, angle=angle, > lwd = lwd) > } > invisible(list(x = xv, y = yv)) > } > > Now run your call to pdf with draw.circle2 instead of draw.circle. This is just idle curiosity, since I'm not really able to contribute anything useful, but I can't resist asking: When I try to run the OP's code I get an error: > Error in alpha("red", 0.4) : could not find function "alpha". Sorry for the lack of precision, alpha is just to add some transparency to the color. This alpha parameter ranges from 0 fully transparent to 1, full color.I don't remember having loaded any package to use this function, I think it is there in base R. Why does this (apparently) not happen to anyone else? Why does the universe pick on *me*? What is the function "alpha()"? Where is it to be found? Searching on "alpha" is of course completely unproductive; there are far too many (totally irrelevant) instances. cheers, Rolf -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R-es] Regresión ponderada
Si, lo intenté tomando logaritmos naturales y los datos están aproximadamente en una línea recta. Las desviaciones (visualmente) parecen mas homogéneas, pero no estoy seguro de que si solamente con la transformación logarítmica estoy resolviendo el problema o solo estoy escondiendo el problema. Saludos, Gerardo 2017-06-14 14:55 GMT-05:00 Carlos J. Gil Bellosta: > Hola, ¿qué tal? > > Una pregunta muy tonta: ¿has tomado logaritmos? > > La dispersión que dices que es muy alta al principio, ¿sigue siendo muy > superior a la del final después de tomar logaritmos? > > Porque si lo que tienes es un decaimiento exponencial, después de tomar > logaritmos deberías ver algo parecido a una recta, la típica que acompaña > en los textos a la regresión lineal simple. Y si no, no tienes decaimiento > exponencial sino otra cosa. > > Un saludo, > > Carlos J. Gil Bellosta > http://www.datanalytics.com > > El 14 de junio de 2017, 21:35, Gerardo Gold > escribió: > >> Colegas: >> >> Necesito hacer una serie de ajustes de un modelo de decaimiento >> exponencial >> a unos datos de concentración de compuestos fluorescentes contra el >> tiempo. >> Para la mayoría de los experimentos tengo tres réplicas por cada tiempo, y >> haciendo los gráficos correspondientes parece haber diferencias muy >> grandes >> en la dispersión de los datos, siendo generalmente mas grandes al >> principio >> del experimento que al final. >> >> Quiero hacer el ajuste de un modelo ponderado para tomar en cuenta las >> diferencias en la dispersión de los datos. Tengo los datos en un "data >> frame" donde tengo los tiempos en una columna, y los valores de >> concentración en otra. Los datos están en forma individual, o sea que >> tengo >> por lo menos tres valores de concentración por cada tiempo. >> >> Para el caso de datos agrupados, donde ya se tiene la desviación estándar >> o >> varianza calculada ajustar un modelo ponderado es fácil, pero no se como >> hacerlo con datos sin agrupar. >> >> Podría alguien ayudarme por favor? >> >> Gracias anticipadas, >> >> Gerardo >> >> [[alternative HTML version deleted]] >> >> ___ >> R-help-es mailing list >> R-help-es@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-help-es >> > > [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R] [FORGED] Re: draw stripes in a circle in R
On 15/06/17 05:29, David Winsemius wrote: On Jun 14, 2017, at 10:18 AM, David Winsemiuswrote: On Jun 14, 2017, at 9:46 AM, Jeff Newmiller wrote: I don't see a question. If your question is whether R supports pattern fills, AFAIK it does not. If that is not your question, ask one. -- Sent from my phone. Please excuse my brevity. On June 14, 2017 7:57:41 AM PDT, jean-philippe wrote: dear R users, I would like to fill a circle with yellow stripes instead of a uniform yellow color. To draw the circle I used the following command after having loaded the (very nice !) plotrix library : I finally understood the question and it needs a hack to the draw.circle function in plotrix since the angle and density arguments don't get passed in: First get code for draw.circle: -- draw.circle # then copy to console and edit draw.circle2 <- function (x, y, radius, nv = 100, border = NULL, col = NA, lty = 1, density=NA, angle=45, lwd = 1 ) { xylim <- par("usr") plotdim <- par("pin") ymult <- getYmult() angle.inc <- 2 * pi/nv angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) if (length(col) < length(radius)) col <- rep(col, length.out = length(radius)) for (circle in 1:length(radius)) { xv <- cos(angles) * radius[circle] + x yv <- sin(angles) * radius[circle] * ymult + y polygon(xv, yv, border = border, col = col, lty = lty, density=density, angle=angle, lwd = lwd) } invisible(list(x = xv, y = yv)) } Now run your call to pdf with draw.circle2 instead of draw.circle. This is just idle curiosity, since I'm not really able to contribute anything useful, but I can't resist asking: When I try to run the OP's code I get an error: Error in alpha("red", 0.4) : could not find function "alpha". Why does this (apparently) not happen to anyone else? Why does the universe pick on *me*? What is the function "alpha()"? Where is it to be found? Searching on "alpha" is of course completely unproductive; there are far too many (totally irrelevant) instances. cheers, Rolf -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reading data
Hi Jim, With a little dig on my side , I have found the issue as to why the script is skipping that file. The file is "ISO-8859 text, with CRLF line terminators" The file should be ASCII and I changed using dos2unix and CRLF line terminators is eliminated but still I am not reading it. How can I read those files with "ISO-8859 text"? On Tue, Jun 13, 2017 at 7:20 PM, jim holtmanwrote: > You need to provide reproducible data. What does the file contain? Why are > you using 'sep=' when reading fixed format. You might be able to attach the > '.txt' to your email to help with the problem. Also you did not state what > the differences that you are seeing. So help us out here. > > > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? > Tell me what you want to do, not how you want to do it. > > On Tue, Jun 13, 2017 at 5:09 PM, Ashta wrote: >> >> Hi all, >> >> I am using R to extract data on a regular basis. >> However, sometimes using the same script and the same data I am >> getting different observation. >> The library I am using and how I am reading it is as follows. >> >> library(stringr) >> namelist <- file("Adress1.txt",encoding="ISO-8859-1") >> Name <- read.fwf(namelist, >> colClasses="character", skip=2,sep="\t",fill=T, >> width =c(2,8,1,1,1,1,1,1,9,5)+1,col.names=ccol) >> >> Can some one suggest me how track the issue? >> Is it the library issue or Java issue? >> May I read as free format instead of fixed format? >> >> Thank you in advance >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R-es] Regresión ponderada
Hola, ¿qué tal? Una pregunta muy tonta: ¿has tomado logaritmos? La dispersión que dices que es muy alta al principio, ¿sigue siendo muy superior a la del final después de tomar logaritmos? Porque si lo que tienes es un decaimiento exponencial, después de tomar logaritmos deberías ver algo parecido a una recta, la típica que acompaña en los textos a la regresión lineal simple. Y si no, no tienes decaimiento exponencial sino otra cosa. Un saludo, Carlos J. Gil Bellosta http://www.datanalytics.com El 14 de junio de 2017, 21:35, Gerardo Goldescribió: > Colegas: > > Necesito hacer una serie de ajustes de un modelo de decaimiento exponencial > a unos datos de concentración de compuestos fluorescentes contra el tiempo. > Para la mayoría de los experimentos tengo tres réplicas por cada tiempo, y > haciendo los gráficos correspondientes parece haber diferencias muy grandes > en la dispersión de los datos, siendo generalmente mas grandes al principio > del experimento que al final. > > Quiero hacer el ajuste de un modelo ponderado para tomar en cuenta las > diferencias en la dispersión de los datos. Tengo los datos en un "data > frame" donde tengo los tiempos en una columna, y los valores de > concentración en otra. Los datos están en forma individual, o sea que tengo > por lo menos tres valores de concentración por cada tiempo. > > Para el caso de datos agrupados, donde ya se tiene la desviación estándar o > varianza calculada ajustar un modelo ponderado es fácil, pero no se como > hacerlo con datos sin agrupar. > > Podría alguien ayudarme por favor? > > Gracias anticipadas, > > Gerardo > > [[alternative HTML version deleted]] > > ___ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es > [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R-es] Regresión ponderada
Colegas: Necesito hacer una serie de ajustes de un modelo de decaimiento exponencial a unos datos de concentración de compuestos fluorescentes contra el tiempo. Para la mayoría de los experimentos tengo tres réplicas por cada tiempo, y haciendo los gráficos correspondientes parece haber diferencias muy grandes en la dispersión de los datos, siendo generalmente mas grandes al principio del experimento que al final. Quiero hacer el ajuste de un modelo ponderado para tomar en cuenta las diferencias en la dispersión de los datos. Tengo los datos en un "data frame" donde tengo los tiempos en una columna, y los valores de concentración en otra. Los datos están en forma individual, o sea que tengo por lo menos tres valores de concentración por cada tiempo. Para el caso de datos agrupados, donde ya se tiene la desviación estándar o varianza calculada ajustar un modelo ponderado es fácil, pero no se como hacerlo con datos sin agrupar. Podría alguien ayudarme por favor? Gracias anticipadas, Gerardo [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R] draw stripes in a circle in R
> On Jun 14, 2017, at 10:18 AM, David Winsemiuswrote: > > >> On Jun 14, 2017, at 9:46 AM, Jeff Newmiller wrote: >> >> I don't see a question. If your question is whether R supports pattern >> fills, AFAIK it does not. If that is not your question, ask one. >> -- >> Sent from my phone. Please excuse my brevity. >> >> On June 14, 2017 7:57:41 AM PDT, jean-philippe >> wrote: >>> dear R users, >>> >>> I would like to fill a circle with yellow stripes instead of a uniform >>> yellow color. To draw the circle I used the following command after >>> having loaded the (very nice !) plotrix library : I finally understood the question and it needs a hack to the draw.circle function in plotrix since the angle and density arguments don't get passed in: First get code for draw.circle: -- draw.circle # then copy to console and edit draw.circle2 <- function (x, y, radius, nv = 100, border = NULL, col = NA, lty = 1, density=NA, angle=45, lwd = 1 ) { xylim <- par("usr") plotdim <- par("pin") ymult <- getYmult() angle.inc <- 2 * pi/nv angles <- seq(0, 2 * pi - angle.inc, by = angle.inc) if (length(col) < length(radius)) col <- rep(col, length.out = length(radius)) for (circle in 1:length(radius)) { xv <- cos(angles) * radius[circle] + x yv <- sin(angles) * radius[circle] * ymult + y polygon(xv, yv, border = border, col = col, lty = lty, density=density, angle=angle, lwd = lwd) } invisible(list(x = xv, y = yv)) } Now run your call to pdf with draw.circle2 instead of draw.circle Best; David. >>> >>> library(plotrix) >>> pdf("MWE.pdf",width=8, height=8) >>> plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >>> par(new=T) >>> plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >>> par(new=T) >>> polygon(c(seq(-12.5,-8.7,length.out=100), >>> rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), >>> >>> rev(seq(-11.7,-8.7,length.out=100))), >>> col = alpha("red",0.4), border = NA) >>> par(new=T) >>> draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) >>> dev.off() >>> > > Agree that the coding question remains unclear, so not using the offered > example but responding to the natural language query. The `polygon` function > has 'density' and 'angle' argument that with 'col' and 'lwd' can make slanted > fill lines. This is a modification of hte first example on `?polygon`? > > x <- c(1:9, 8:1) > y <- c(1, 2*(5:3), 2, -1, 17, 9, 8, 2:9) > op <- par(mfcol = c(3, 1)) > for(xpd in c(FALSE, TRUE, NA)) { >plot(1:10, main = paste("xpd =", xpd)) >box("figure", col = "pink", lwd = 3) >polygon(x, y, xpd = xpd, col = "orange", density=3, angle=45, lwd = 5, > border = "red") > } > > The polygon function is _not_ in pkg::plotrix. > > > >>> It looks a bit ugly since they are not real data, but it is the >>> simplest >>> MWE example that I found. >>> >>> >>> Thanks, best >>> >>> >>> Jean-Philippe >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > David Winsemius > Alameda, CA, USA > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] draw stripes in a circle in R
> On Jun 14, 2017, at 9:46 AM, Jeff Newmillerwrote: > > I don't see a question. If your question is whether R supports pattern fills, > AFAIK it does not. If that is not your question, ask one. > -- > Sent from my phone. Please excuse my brevity. > > On June 14, 2017 7:57:41 AM PDT, jean-philippe > wrote: >> dear R users, >> >> I would like to fill a circle with yellow stripes instead of a uniform >> yellow color. To draw the circle I used the following command after >> having loaded the (very nice !) plotrix library : >> >> library(plotrix) >> pdf("MWE.pdf",width=8, height=8) >> plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >> par(new=T) >> plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >> par(new=T) >> polygon(c(seq(-12.5,-8.7,length.out=100), >> rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), >> >> rev(seq(-11.7,-8.7,length.out=100))), >>col = alpha("red",0.4), border = NA) >> par(new=T) >> draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) >> dev.off() >> Agree that the coding question remains unclear, so not using the offered example but responding to the natural language query. The `polygon` function has 'density' and 'angle' argument that with 'col' and 'lwd' can make slanted fill lines. This is a modification of hte first example on `?polygon`? x <- c(1:9, 8:1) y <- c(1, 2*(5:3), 2, -1, 17, 9, 8, 2:9) op <- par(mfcol = c(3, 1)) for(xpd in c(FALSE, TRUE, NA)) { plot(1:10, main = paste("xpd =", xpd)) box("figure", col = "pink", lwd = 3) polygon(x, y, xpd = xpd, col = "orange", density=3, angle=45, lwd = 5, border = "red") } The polygon function is _not_ in pkg::plotrix. >> It looks a bit ugly since they are not real data, but it is the >> simplest >> MWE example that I found. >> >> >> Thanks, best >> >> >> Jean-Philippe > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] draw stripes in a circle in R
Sorry for that. Yes my question was whether or not and how is it possible to fill a circle of yellow stripes in R? Is it something that I have to precise in the color argument? Thanks, best Envoyé depuis mon appareil Samsung Message d'origine De : Jeff NewmillerDate : 14/06/2017 18:46 (GMT+01:00) À : r-help@r-project.org, jean-philippe , r-help@R-project.org Objet : Re: [R] draw stripes in a circle in R I don't see a question. If your question is whether R supports pattern fills, AFAIK it does not. If that is not your question, ask one. -- Sent from my phone. Please excuse my brevity. On June 14, 2017 7:57:41 AM PDT, jean-philippe wrote: >dear R users, > >I would like to fill a circle with yellow stripes instead of a uniform >yellow color. To draw the circle I used the following command after >having loaded the (very nice !) plotrix library : > >library(plotrix) >pdf("MWE.pdf",width=8, height=8) >plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >par(new=T) >plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >par(new=T) >polygon(c(seq(-12.5,-8.7,length.out=100), >rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), > >rev(seq(-11.7,-8.7,length.out=100))), > col = alpha("red",0.4), border = NA) >par(new=T) >draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) >dev.off() > >It looks a bit ugly since they are not real data, but it is the >simplest >MWE example that I found. > > >Thanks, best > > >Jean-Philippe [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] draw stripes in a circle in R
I don't see a question. If your question is whether R supports pattern fills, AFAIK it does not. If that is not your question, ask one. -- Sent from my phone. Please excuse my brevity. On June 14, 2017 7:57:41 AM PDT, jean-philippewrote: >dear R users, > >I would like to fill a circle with yellow stripes instead of a uniform >yellow color. To draw the circle I used the following command after >having loaded the (very nice !) plotrix library : > >library(plotrix) >pdf("MWE.pdf",width=8, height=8) >plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >par(new=T) >plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) >par(new=T) >polygon(c(seq(-12.5,-8.7,length.out=100), >rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), > >rev(seq(-11.7,-8.7,length.out=100))), > col = alpha("red",0.4), border = NA) >par(new=T) >draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) >dev.off() > >It looks a bit ugly since they are not real data, but it is the >simplest >MWE example that I found. > > >Thanks, best > > >Jean-Philippe __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] draw stripes in a circle in R
dear R users, I would like to fill a circle with yellow stripes instead of a uniform yellow color. To draw the circle I used the following command after having loaded the (very nice !) plotrix library : library(plotrix) pdf("MWE.pdf",width=8, height=8) plot(seq(-12.5,-8.7,length.out=100),seq(-11.3,-8.3,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) par(new=T) plot(seq(-12.5,-8.7,length.out=100),seq(-11.7,-8.7,length.out=100),type="l",col="red",xlim=c(-12.5,-8.7),ylim=c(-11.5,-8.5)) par(new=T) polygon(c(seq(-12.5,-8.7,length.out=100), rev(seq(-12.5,-8.7,length.out=100))), c(seq(-11.3,-8.3,length.out=100), rev(seq(-11.7,-8.7,length.out=100))), col = alpha("red",0.4), border = NA) par(new=T) draw.circle(-12.85,-10.9,0.85,nv=1000,border=NULL,col="yellow",lty=1,lwd=1) dev.off() It looks a bit ugly since they are not real data, but it is the simplest MWE example that I found. Thanks, best Jean-Philippe -- Jean-Philippe Fontaine PhD Student in Astroparticle Physics, Gran Sasso Science Institute (GSSI), Viale Francesco Crispi 7, 67100 L'Aquila, Italy Mobile: +393487128593, +33615653774 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot MArginal distribution in the correct place
Please can you send me some orientation? Many thanks in advance. Only if posible one book o similar example to understand why it is not what I try. El 8 jun. 2017 7:50 PM, "Pedro páramo"escribió: > Many thanks Jim. > > What I,m trying to show with the fhist plot is the empirical distribution > of the values of the left plot simulation. > > You say: > However, I don't think that this plot illustrates quite what you think it > does. > > Can you give me a clue to try to illustrate better if it is not showing > what I believe it shows a better way to show it? > > Many thanks in advance. > > > > > > El 7 jun. 2017 12:08, "Jim Lemon" escribió: > > Hi Pedro, > As a one-off, you just shove the coordinates around a bit: > > par(mar=c(11,0,6,6)) > barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray", > ylim=c(0,24)) > > However, I don't think that this plot illustrates quite what you think it > does. > > Jim > > > On Wed, Jun 7, 2017 at 4:01 PM, Pedro páramo > wrote: > > Please, I'm trying to put the right plot higher and centered on the left > > values but I don't achive. > > > > I would appreciate so much your help > > > > El 6 jun. 2017 22:37, "Pedro páramo" escribió: > > > >> Hi all, > >> > >> I have this code, but the marginal distribution plot doesn´t appear > >> aligned with the left plot. > >> > >> > >> I think could be something about layout or par() mar. > >> > >> The code was programmed by me time ago. > >> > >> Can anyone help me to get the marginal distribution on the center (more > >> higher centered) > >> > >> id.txt > >> > >> Could have this code: > >> > >> 05/01/2016;9335,200195 > >> 06/01/2016;9197,400391 > >> 07/01/2016;9059,299805 > >> 08/01/2016;8909,200195 > >> 11/01/2016;8886,099609 > >> 12/01/2016;8915,400391 > >> 13/01/2016;8934,5 > >> 14/01/2016;8787,700195 > >> 15/01/2016;8543,599609 > >> 18/01/2016;8469,299805 > >> 19/01/2016;8554,900391 > >> 20/01/2016;8281,400391 > >> 21/01/2016;8444,200195 > >> 22/01/2016;8722,900391 > >> 25/01/2016;8567,700195 > >> 26/01/2016;8692,5 > >> 27/01/2016;8741 > >> > >> > >> > >> g<-read.table("id.txt", col.names=c("Dateh","LAST"), sep=";", dec=",") > >> > >> N=5000 > >> B=24 > >> ghy<-nrow(g) > >> r<-as.numeric(as.character(g$LAST[ghy])) > >> > >> > >> nf<-layout(matrix(c(1,1,1,1,2,2),1,6,byrow=TRUE)) > >> > >> par(mar=c(6,6,6,0.5)) > >> > >> A<-matrix(1:B,B,N); > >> > >> > >> > >> sigma<-0.06; > >> > >> > >> > >> mu<-0.00; > >> > >> > >> Z<-r*exp((mu-0.5*((sigma)^2)*A) +sigma*(sqrt(A))*matrix( > rnorm(N*B,0,1), > >> B, N)) > >> > >> real1<-g$LAST[1:nrow(g)] > >> > >> real2<-matrix(NA,nrow(g),N-1) > >> > >> real<-cbind(real1,real2) > >> > >> > >> > >> > >> Po<-r*matrix(1,1,N); > >> > >> > >> > >> Sim<-rbind(Po,Z) > >> Simulation<-rbind(real,Z) > >> > >> > >> > >> > >> > >> > >> par(mar=c(10,6,6,6)) > >> matplot(Simulation,type="l",ylim=c(0,4)) > >> > >> abline(h = 8000, lwd = 2, col = "black") > >> > >> abline(h = 12000, lwd = 2, col = "black") > >> title("Dinamic Montecarlo Simulation 2 years ahead",font=4) > >> > >> fhist<-hist(Simulation,plot=FALSE) > >> par(mar=c(6,0,6,6)) > >> barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray") > >> grid() > >> title("Marginal Distribution",font=4) > >> > >> > >> rect(0, 0, 0, 0) # transparent > >> > >> > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posti > ng-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot MArginal distribution in the correct place
Hi Pedro, If you keep that same margins for the second plot: par(mar=c(10,0,6,6)) barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray") it looks reasonably well aligned to me. Because you are plotting the counts of the values in Simulation, the ordinate (vertical axis) of the bar plot is in quite different units from that of the plot on the left side. Jim On Wed, Jun 14, 2017 at 5:33 PM, Pedro páramowrote: > Please can you send me some orientation? > > Many thanks in advance. > > Only if posible one book o similar example to understand why it is not what > I try. > > El 8 jun. 2017 7:50 PM, "Pedro páramo" escribió: >> >> Many thanks Jim. >> >> What I,m trying to show with the fhist plot is the empirical distribution >> of the values of the left plot simulation. >> >> You say: >> However, I don't think that this plot illustrates quite what you think it >> does. >> >> Can you give me a clue to try to illustrate better if it is not showing >> what I believe it shows a better way to show it? >> >> Many thanks in advance. >> >> >> >> >> >> El 7 jun. 2017 12:08, "Jim Lemon" escribió: >> >> Hi Pedro, >> As a one-off, you just shove the coordinates around a bit: >> >> par(mar=c(11,0,6,6)) >> barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray", >> ylim=c(0,24)) >> >> However, I don't think that this plot illustrates quite what you think it >> does. >> >> Jim >> >> >> On Wed, Jun 7, 2017 at 4:01 PM, Pedro páramo >> wrote: >> > Please, I'm trying to put the right plot higher and centered on the left >> > values but I don't achive. >> > >> > I would appreciate so much your help >> > >> > El 6 jun. 2017 22:37, "Pedro páramo" escribió: >> > >> >> Hi all, >> >> >> >> I have this code, but the marginal distribution plot doesn´t appear >> >> aligned with the left plot. >> >> >> >> >> >> I think could be something about layout or par() mar. >> >> >> >> The code was programmed by me time ago. >> >> >> >> Can anyone help me to get the marginal distribution on the center (more >> >> higher centered) >> >> >> >> id.txt >> >> >> >> Could have this code: >> >> >> >> 05/01/2016;9335,200195 >> >> 06/01/2016;9197,400391 >> >> 07/01/2016;9059,299805 >> >> 08/01/2016;8909,200195 >> >> 11/01/2016;8886,099609 >> >> 12/01/2016;8915,400391 >> >> 13/01/2016;8934,5 >> >> 14/01/2016;8787,700195 >> >> 15/01/2016;8543,599609 >> >> 18/01/2016;8469,299805 >> >> 19/01/2016;8554,900391 >> >> 20/01/2016;8281,400391 >> >> 21/01/2016;8444,200195 >> >> 22/01/2016;8722,900391 >> >> 25/01/2016;8567,700195 >> >> 26/01/2016;8692,5 >> >> 27/01/2016;8741 >> >> >> >> >> >> >> >> g<-read.table("id.txt", col.names=c("Dateh","LAST"), sep=";", dec=",") >> >> >> >> N=5000 >> >> B=24 >> >> ghy<-nrow(g) >> >> r<-as.numeric(as.character(g$LAST[ghy])) >> >> >> >> >> >> nf<-layout(matrix(c(1,1,1,1,2,2),1,6,byrow=TRUE)) >> >> >> >> par(mar=c(6,6,6,0.5)) >> >> >> >> A<-matrix(1:B,B,N); >> >> >> >> >> >> >> >> sigma<-0.06; >> >> >> >> >> >> >> >> mu<-0.00; >> >> >> >> >> >> Z<-r*exp((mu-0.5*((sigma)^2)*A) +sigma*(sqrt(A))*matrix( >> >> rnorm(N*B,0,1), >> >> B, N)) >> >> >> >> real1<-g$LAST[1:nrow(g)] >> >> >> >> real2<-matrix(NA,nrow(g),N-1) >> >> >> >> real<-cbind(real1,real2) >> >> >> >> >> >> >> >> >> >> Po<-r*matrix(1,1,N); >> >> >> >> >> >> >> >> Sim<-rbind(Po,Z) >> >> Simulation<-rbind(real,Z) >> >> >> >> >> >> >> >> >> >> >> >> >> >> par(mar=c(10,6,6,6)) >> >> matplot(Simulation,type="l",ylim=c(0,4)) >> >> >> >> abline(h = 8000, lwd = 2, col = "black") >> >> >> >> abline(h = 12000, lwd = 2, col = "black") >> >> title("Dinamic Montecarlo Simulation 2 years ahead",font=4) >> >> >> >> fhist<-hist(Simulation,plot=FALSE) >> >> par(mar=c(6,0,6,6)) >> >> barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray") >> >> grid() >> >> title("Marginal Distribution",font=4) >> >> >> >> >> >> rect(0, 0, 0, 0) # transparent >> >> >> >> >> > >> > [[alternative HTML version deleted]] >> > >> > __ >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> > http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> >> > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.