Re: [R] Column names of model.matrix's output with contrast.arg
Thanks for your reply. It might good to document the naming convention in ?contrasts. It is hard to understand .L for linear, .Q for quadratic, .C for cubic and ^n for other degrees. For contr.sum, we could have used .Sum, .Sum… Maybe the examples ?model.matrix should use names in dd objects so that we observe when names are dropped. Kind regards, Christophe > Le 14 juin 2024 à 11:45, peter dalgaard a écrit : > > You're at the mercy of the various contr.XXX functions. They may or may not > set the colnames on the matrices that they generate. > > The rationales for (not) setting them is not perfectly transparent, but you > obviously cannot use level names on contr.poly, so it uses .L, .Q, etc. > > In MASS, contr.sdif is careful about labeling the columns with the levels > that are being diff'ed. > > For contr.treatment, there is a straightforward connection to 0/1 dummy > variables, so level names there are natural. > > One could use levels in contr.sum and contr.helmert, but it might confuse > users that comparisons are with the average of all levels or preceding > levels. (It can be quite confusing when coding is +1 for male and -1 for > female, so that the gender difference is twice the coefficient.) > > -pd > >> On 14 Jun 2024, at 08:12 , Christophe Dutang wrote: >> >> Dear list, >> >> Changing the default contrasts used in glm() makes me aware how >> model.matrix() set column names. >> >> With default contrasts, model.matrix() use the level values to name the >> columns. However with other contrasts, model.matrix() use the level indexes. >> In the documentation, I don’t see anything in the documentation related to >> this ? It does not seem natural to have such a behavior? >> >> Any comment is welcome. >> >> An example is below. >> >> Kind regards, Christophe >> >> >> #example from ?glm >> counts <- c(18,17,15,20,10,20,25,13,12) >> outcome <- paste0("O", gl(3,1,9)) >> treatment <- paste0("T", gl(3,3)) >> >> X3 <- model.matrix(counts ~ outcome + treatment) >> X4 <- model.matrix(counts ~ outcome + treatment, contrasts = >> list("outcome"="contr.sum")) >> X5 <- model.matrix(counts ~ outcome + treatment, contrasts = >> list("outcome"="contr.helmert")) >> >> #check with original factor >> cbind.data.frame(X3, outcome) >> cbind.data.frame(X4, outcome) >> cbind.data.frame(X5, outcome) >> >> #same issue with glm >> glm.D93 <- glm(counts ~ outcome + treatment, family = poisson()) >> glm.D94 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = >> list("outcome"="contr.sum")) >> glm.D95 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = >> list("outcome"="contr.helmert")) >> >> coef(glm.D93) >> coef(glm.D94) >> coef(glm.D95) >> >> #check linear predictor >> cbind(X3 %*% coef(glm.D93), predict(glm.D93)) >> cbind(X4 %*% coef(glm.D94), predict(glm.D94)) >> >> - >> Christophe DUTANG >> LJK, Ensimag, Grenoble INP, UGA, France >> ILB research fellow >> Web: http://dutangc.free.fr >> >> __ >> 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. > > -- > Peter Dalgaard, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Office: A 4.23 > Email: pd@cbs.dk Priv: pda...@gmail.com > __ 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] Column names of model.matrix's output with contrast.arg
Dear list, Changing the default contrasts used in glm() makes me aware how model.matrix() set column names. With default contrasts, model.matrix() use the level values to name the columns. However with other contrasts, model.matrix() use the level indexes. In the documentation, I don’t see anything in the documentation related to this ? It does not seem natural to have such a behavior? Any comment is welcome. An example is below. Kind regards, Christophe #example from ?glm counts <- c(18,17,15,20,10,20,25,13,12) outcome <- paste0("O", gl(3,1,9)) treatment <- paste0("T", gl(3,3)) X3 <- model.matrix(counts ~ outcome + treatment) X4 <- model.matrix(counts ~ outcome + treatment, contrasts = list("outcome"="contr.sum")) X5 <- model.matrix(counts ~ outcome + treatment, contrasts = list("outcome"="contr.helmert")) #check with original factor cbind.data.frame(X3, outcome) cbind.data.frame(X4, outcome) cbind.data.frame(X5, outcome) #same issue with glm glm.D93 <- glm(counts ~ outcome + treatment, family = poisson()) glm.D94 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = list("outcome"="contr.sum")) glm.D95 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = list("outcome"="contr.helmert")) coef(glm.D93) coef(glm.D94) coef(glm.D95) #check linear predictor cbind(X3 %*% coef(glm.D93), predict(glm.D93)) cbind(X4 %*% coef(glm.D94), predict(glm.D94)) - Christophe DUTANG LJK, Ensimag, Grenoble INP, UGA, France ILB research fellow Web: http://dutangc.free.fr __ 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] Fitting Mixed Distributions in the fitdistrplus package
Dear Charles, Please, when you have questions about fitdistrplus, contact directly the authors of the package and not R-help. When fitting non « standard » distributions with fitdistrplus, you should define by yourself the density and the cumulative distribution functions, or load a package which define them. See FAQ for a general example : https://cran.r-project.org/web/packages/fitdistrplus/vignettes/FAQ.html#how-do-i-find-non-standard-distributions ? Regarding your mixed distribution, the code below works correctly. By the way, the Feller-Pareto distribution (see actual) is among the best distributions for the Danish dataset. You may also consider composite distributions, see https://CRAN.R-project.org/view=Distributions Kind regards, Christophe dmixgam <- function(x, prob, shape1, scale1, shape2, scale2) prob*dgamma(x, shape1, scale=scale1)+ (1-prob)*dpareto(x, shape2, scale=scale2) pmixgam <- function(q, prob, shape1, scale1, shape2, scale2) prob*pgamma(q, shape1, scale=scale1)+ (1-prob)*ppareto(q, shape2, scale=scale2) library(actuar) library(fitdistrplus) data("danishuni") x<- danishuni$Loss fgam<- fitdist(x,"gamma",lower=0) fpar<- fitdist(x,"pareto",start = list(shape=2,scale=2),lower=0) fmixgam<- fitdist(x,"mixgam",start = list(prob=1/2,shape1=1,scale1=1,shape2=1,scale2=1),lower=0) cdfcomp(list(fgam, fpar, fmixgam), xlogscale = TRUE) gofstat(list(fgam, fpar, fmixgam)) > > -- Forwarded message - > From: Charles Thuo > Date: Wed, Oct 21, 2020 at 12:03 AM > Subject: [R] Fitting Mixed Distributions in the fitdistrplus package > To: > > > Dear Sirs, > > The below listed code fits a gamma and a pareto distribution to a data set > danishuni. However the distributions are not appropriate to fit both tails > of the data set hence a mixed distribution is required which has ben > defined as "mixgampar" > as shown below. > > library(fitdistrplus) > x<- danishuni$Loss > fgam<- fitdist(x,"gamma",lower=0) > fpar<- fitdist(x,"pareto",start = list(shape=2,scale=2),lower=0) > fmixgampar<- fitdist(x,"mixgampar",start = > list(prob=1/2,nu=1,lambda=1,alpha=1,theta=1),lower=0) > Error in fitdist(x, "mixgampar", start = list(prob = 1/2, nu = 1, lambda = > 1, : > > The dmixgampar function must be defined > > Kindly assist to define the dmixgampar > > Charkes > >[[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] Fitdistrplus and Parameter Constraints
Dear Lorenzo, Please do read the posting guide (https://www.r-project.org/posting-guide.html) : The ‘main’ R mailing list, for discussion about problems and solutions using R, about the availability of new functionality for R and documentation of R, comparison and compatibility with S-plus, and for the posting of nice examples and benchmarks. For your problem, you could do something like this x <- rbeta(1000, 3, 3) dbeta2 <- function(x, shape, ...) dbeta(x, shape, shape, ...) pbeta2 <- function(q, shape, ...) pbeta(q, shape, shape, ...) library(fitdistrplus) fitdist(x, "beta2", start=list(shape=1/2)) x <- rbeta(1000, .3, .3) fitdist(x, "beta2", start=list(shape=1/2), optim.method="L-BFGS-B", lower=1e-2) Regards, Christophe --- Christophe Dutang LMM, UdM, Le Mans, France web: http://dutangc.free.fr > Le 23 mai 2017 à 18:22, Lorenzo Isella a écrit : > > Dear All, > In principle it is a simple question, but not idea about how to tackle > it. > Suppose you have a distribution depending on two parameters, > e.g. beta(a,b). > For some reasons, you want to impose > that the two parameters of the beta distribution are identical, > i.e. you want to fit your data to beta(a,a). > For instance > > x<-rbeta(1000, 0.1, 0.1) > require(fitdistrplus) > > mm<-fitdist(x, "beta", method = "mge") > > > is how you would normally fit a sample, but I do not know how to > impose the constrain a=b before the fitting. > Any suggestion is appreciated. > Cheers > > Lorenzo __ 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] linking vignettes in a man page
Thanks both to your answer. In my case, I link both html and pdf vignetttes with \href, typically \href{../doc/FAQ.html}{Frequently Asked Questions}. Maybe Duncan, you could add your answer based on \url{../doc/} and \url{../..//help/} as a complement in Section 2.5 of Writing R extensions? I spent quite a lot of time searching how to do this. Regards, Christophe --- Christophe Dutang LMM, UdM, Le Mans, France web: http://dutangc.free.fr <http://dutangc.free.fr/> > Le 29 juin 2016 � 23:27, Duncan Murdoch a �crit : > > On 29/06/2016 4:49 PM, Christophe Dutang wrote: >> Dear list, >> >> How can I link a vignette of a package in a man page (Rd files)? >> >> I try \link[=pkgname/doc/filename]{a name} without success. >> >> The link gives the following error message: Only help files, NEWS, >> DESCRIPTION and files under doc/ and demo/ in a package can be viewed > > > You can give \url{} style links, for example the grid package has > > \url{../doc/grid.pdf} > > in the package?grid help topic. Similarly, ../..//help/ will > link from a vignette to help topic ?alias. > > Duncan Murdoch > > > [[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] linking vignettes in a man page
Dear list, How can I link a vignette of a package in a man page (Rd files)? I try \link[=pkgname/doc/filename]{a name} without success. The link gives the following error message: Only help files, NEWS, DESCRIPTION and files under doc/ and demo/ in a package can be viewed Thanks in advance Kind regards, Christophe --- Christophe Dutang LMM, UdM, Le Mans, France web: http://dutangc.free.fr __ 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] on the output of constrOptim()
Dear list, The following example of constrOptim() where the initial point is the solution shows that the component counts is not a two-element vector as documented in the man page. constrOptim(c(1,1), fr, grr, ui = diag(2), ci = c(0,0)) Does anyone have the same behavior? A possible solution is to put line 69 in constrOptim.R before the first possible break line 67. Regards, Christophe > sessionInfo() R version 3.2.4 (2016-03-10) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.10.5 (Yosemite) locale: [1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] nlstools_1.0-2 fitdistrplus_1.0-7 survival_2.38-3MASS_7.3-45 loaded via a namespace (and not attached): [1] tools_3.2.4 splines_3.2.4 --- Christophe Dutang LMM, UdM, Le Mans, France web: http://dutangc.free.fr <http://dutangc.free.fr/> [[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] Find the dataset(s) that contain(s) non-ASCII characters
Dear list, I’m maintainsing a package containing only datasets (152): http://dutangc.free.fr/pub/RRepos/web/CASdatasets-index.html <http://dutangc.free.fr/pub/RRepos/web/CASdatasets-index.html> When R CMD checking the package, I get the following NOTE * checking data for non-ASCII characters ... NOTE Note: found 4 marked UTF-8 strings I wonder how to find which dataset(s) (all recorded as rda files) contain(s) non-ASCII characters. Using the iconv function let us to find or replace non-ASCII characters iconv(x, "UTF-8", "ASCII", sub="I_WAS_NOT_ASCII") I use the following function to detect non-ASCII characters. testASCII <- function(idata) { col <- (1:NCOL(idata))[sapply(idata, is.factor)] col <- c(col, (1:NCOL(idata))[sapply(idata, is.character)]) for(i in col) { x <- idata[, i] cat(colnames(idata)[i], "\n") res <- grep("I_WAS_NOT_ASCII", iconv(x, "latin1", "ASCII", sub="I_WAS_NOT_ASCII")) res <- c(res, grep("I_WAS_NOT_ASCII", iconv(x, "UTF-8", "ASCII", sub="I_WAS_NOT_ASCII"))) if(any(length(res) > 0)) cat(res, "\n") } } Unfortunately, I did not find yet which rda file contains non-ASCII characters among 56 most recent datasets. Is there a faster way to detect non-ASCII characters than to manually load and testASCII()? for example directly on rda files? Any comment is welcome. Regards, Christophe > sessionInfo() R version 3.2.4 (2016-03-10) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.10.5 (Yosemite) locale: [1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base --- Christophe Dutang LMM, UdM, Le Mans, France web: http://dutangc.free.fr <http://dutangc.free.fr/> [[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] "Nash Equilibrium"
Finally, I decided not to depends on SQUAREM, which I used for testing. Nevertherless extrapolation methods for fixed point iteration are at least twice faster than the crude fixed-point iteration or other relaxation methods. Later I would like to do a real benchmark of all methods, not just fixed-point iterations. Christophe Le 4 déc. 2010 à 15:49, Ravi Varadhan a écrit : > > Hi Christophe, > > Aren't you also using fixed-point acceleration schemes (from the SQUAREM > package) for solving the Nash equilibria? > > How does fixed-point acceleration approach compare to the optimization > approach in terms of speed and robustness (i.e. convergence from bad starting > values)? > > Ravi. > > > Ravi Varadhan, Ph.D. > Assistant Professor, > Division of Geriatric Medicine and Gerontology > School of Medicine > Johns Hopkins University > > Ph. (410) 502-2619 > email: rvarad...@jhmi.edu > > > - Original Message - > From: Christophe Dutang > Date: Saturday, December 4, 2010 5:09 am > Subject: Re: [R] "Nash Equilibrium" > To: Ravi Varadhan , ivo welch > Cc: r-help > > >> Hello all, >> >> Months ago, when I wanted to compute Nash equilibria (both standard >> and generalized), I only found one package that implements the >> discrete, i.e. when the player payoff is represented by a matrix. So I >> decided to implement the computation when the payoff is a continuous >> payoff, generally on a compact set. >> >> The project NE computation is available on R-forge (, there is one >> package called GNE computing generalized Nash Equilibria. >> >> Two days ago, I commit a first stable and documented version. Please >> download the binary from the "R packages" tab. The package depends on >> the alabama package, which depends also on numDeriv. So you need to >> download these two packages as well. >> >> Once loaded, ?GNE is an overview of the package. I put 3 examples of >> GNE in the man page taken from von Heusinger & Kanzow (2009). >> >> Christophe >> >> PS: send me an email if you have problems with the functions. >> >> Le 4 déc. 2010 à 00:25, Ravi Varadhan a écrit : >> >>> I think Christophe Dutang is writing a package for generalized Nash >>> Equilibria models called "GNE". >>> >>> I am cc'ing him here. >>> >>> I don't know if there are other packages out there. Christophe >> would know. >>> >>> Ravi. >>> >>> --- >>> Ravi Varadhan, Ph.D. >>> Assistant Professor, >>> Division of Geriatric Medicine and Gerontology School of Medicine Johns >>> Hopkins University >>> >>> Ph. (410) 502-2619 >>> email: rvarad...@jhmi.edu >>> >>> >>> -Original Message- >>> From: r-help-boun...@r-project.org [ On >>> Behalf Of ivo welch >>> Sent: Friday, December 03, 2010 5:40 PM >>> To: r-help >>> Subject: [R] "Nash Equilibrium" >>> >>> Dear R experts: >>> >>> I searched cran (and r-help) for "nash equilibrium" and "game" but >>> nothing stuck out. has someone written a numerical nash optimizer for >>> two players? >>> >>> player a has choices x1,x2,x3,... and cares about (maximizes) >>> pa(x1,x2,x3,...,y1,y2,y3) >>> player b has choices y1,y2,y3,..., and cares about (maximizes) >>> pb(x1,x2,x3,...,y1,y2,y3) >>> >>> I can tune it to my problem, but if someone has already invented this, >>> please point me to it, so that I do not have to reinvent the wheel. >>> >>> regards, >>> >>> /iaw >>> >>> >>> Ivo Welch (ivo.we...@brown.edu, ivo.we...@gmail.com) >>> >>> __ >>> R-help@r-project.org mailing list >>> >>> PLEASE do read the posting guide >>> and provide commented, minimal, self-contained, reproducible code. >>> >> >> -- >> Christophe Dutang >> Ph.D. student at ISFA, Lyon, France >> website: >> >> >> >> >> >> -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.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] "Nash Equilibrium"
Hello all, Months ago, when I wanted to compute Nash equilibria (both standard and generalized), I only found one package that implements the discrete, i.e. when the player payoff is represented by a matrix. So I decided to implement the computation when the payoff is a continuous payoff, generally on a compact set. The project NE computation is available on R-forge (https://r-forge.r-project.org/R/?group_id=860), there is one package called GNE computing generalized Nash Equilibria. Two days ago, I commit a first stable and documented version. Please download the binary from the "R packages" tab. The package depends on the alabama package, which depends also on numDeriv. So you need to download these two packages as well. Once loaded, ?GNE is an overview of the package. I put 3 examples of GNE in the man page taken from von Heusinger & Kanzow (2009). Christophe PS: send me an email if you have problems with the functions. Le 4 déc. 2010 à 00:25, Ravi Varadhan a écrit : > I think Christophe Dutang is writing a package for generalized Nash > Equilibria models called "GNE". > > I am cc'ing him here. > > I don't know if there are other packages out there. Christophe would know. > > Ravi. > > --- > Ravi Varadhan, Ph.D. > Assistant Professor, > Division of Geriatric Medicine and Gerontology School of Medicine Johns > Hopkins University > > Ph. (410) 502-2619 > email: rvarad...@jhmi.edu > > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of ivo welch > Sent: Friday, December 03, 2010 5:40 PM > To: r-help > Subject: [R] "Nash Equilibrium" > > Dear R experts: > > I searched cran (and r-help) for "nash equilibrium" and "game" but > nothing stuck out. has someone written a numerical nash optimizer for > two players? > > player a has choices x1,x2,x3,... and cares about (maximizes) > pa(x1,x2,x3,...,y1,y2,y3) > player b has choices y1,y2,y3,..., and cares about (maximizes) > pb(x1,x2,x3,...,y1,y2,y3) > > I can tune it to my problem, but if someone has already invented this, > please point me to it, so that I do not have to reinvent the wheel. > > regards, > > /iaw > > > Ivo Welch (ivo.we...@brown.edu, ivo.we...@gmail.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. > -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.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] Debye function
Thank you for your time. I'm looking for another package than the gsl package. But it does not seem to be implemented anywhere else. Christophe Le 4 oct. 2010 à 19:10, Bert Gunter a écrit : > Well, not really ... > > Google on "R package Debye" . The 5th hit lists the gsl package with > the debye() function. > > Moral: DO make use of standard professional search tools, also. > > -- Bert > > On Mon, Oct 4, 2010 at 9:13 AM, Spencer Graves > wrote: >> >> install.packages('sos') # if not already installed >> library(sos) >> Debye <- ???Debye >> #found 4 matches >> Debye # "Print method opens table in a web browser >> >> >> Conclusions: >> >> >>1. There are references to Debye in the "CHNOSZ" package, but it >> may not be what you want. >> >> >>2. If it's otherwise available in R, it's very well concealed. >> >> >> Spencer >> >> >> On 10/4/2010 8:56 AM, Christophe Dutang wrote: >>> >>> Dear list, >>> >>> Is there another package than gsl* where the Debye function (of first >>> order) >>> is implemented? Google only finds the gsl package. >>> >>> Thanks in advance >>> >>> Christophe >>> >>> * page 12 of reference manual of gsl. >>> http://cran.r-project.org/web/packages/gsl/gsl.pdf >> >> >> -- >> Spencer Graves, PE, PhD >> President and Chief Operating Officer >> Structure Inspection and Monitoring, Inc. >> 751 Emerson Ct. >> San José, CA 95126 >> ph: 408-655-4567 >> >> __ >> 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. >> > > > > -- > Bert Gunter > Genentech Nonclinical Biostatistics -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.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] Debye function
Dear list, Is there another package than gsl* where the Debye function (of first order) is implemented? Google only finds the gsl package. Thanks in advance Christophe * page 12 of reference manual of gsl. http://cran.r-project.org/web/packages/gsl/gsl.pdf -- Christophe DUTANG Ph. D. student at ISFA, Lyon, France [[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] extended Kalman filter for survival data
Thanks Christos. BayesX was strongly recommended also by Fahrmeir and other people of that field. So it is clearly where I need to look at! Christophe iPhone.fan Le 12 juin 2010 à 04:46, Christos Argyropoulos a écrit : > > If you mean this paper by Fahrmeir: > http://biomet.oxfordjournals.org/cgi/content/abstract/81/2/317 > I would recommend BayesX: http://www.stat.uni-muenchen.de/~bayesx/. > BayesX interfaces with R and estimates discrete (and continuous) > time survival data with penalized regression methods. > If you are looking for a bona fide Bayesian survival analysis method > and do not wish to spend a lot of time coming up and debugging your > MCMC implementations in WinBUGS/JAGS/OpenBUGS this would be the way > to go. > If you are strictly after frequentist analyses then you can still > run them with BayesX (look at the REML chapter in the manual). > > > Christos Argyropoulos > > > > Date: Mon, 3 May 2010 23:18:28 +0200 > > From: duta...@gmail.com > > To: r-help@r-project.org > > Subject: [R] extended Kalman filter for survival data > > > > Dear all, > > > > I'm looking for an implementation of the generalized extended > Kalman filter > > for survival data, presented in this article Fahrmeir (1994) - > 'dynamic > > modelling for discrete time survival data'. The same author also > publish a > > Bayesian version of the algorithm 'dynamic discrete-time duration > models'. > > > > The maintainer of the Survival task view advises me to take a look > at > > http://cran.r-project.org/web/packages/sspir/index.html > > Unfortunately, the pkg implements "only" dynamic GLM. > > > > That's why I'm asking on this list, if someone knows a package for > this > > implementation? > > > > Thanks in advance > > > > Christophe > > > > > > > > PS: the pseudo vignette of the sspir pkg can be found here > > http://www.jstatsoft.org/v16/i01/paper . > > > > -- > > Christophe DUTANG > > Ph. D. student at ISFA > > > > [[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. > > Hotmail: Trusted email with powerful SPAM protection. Sign up now. [[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] extended Kalman filter for survival data
Dear all, I'm looking for an implementation of the generalized extended Kalman filter for survival data, presented in this article Fahrmeir (1994) - 'dynamic modelling for discrete time survival data'. The same author also publish a Bayesian version of the algorithm 'dynamic discrete-time duration models'. The maintainer of the Survival task view advises me to take a look at http://cran.r-project.org/web/packages/sspir/index.html Unfortunately, the pkg implements "only" dynamic GLM. That's why I'm asking on this list, if someone knows a package for this implementation? Thanks in advance Christophe PS: the pseudo vignette of the sspir pkg can be found here http://www.jstatsoft.org/v16/i01/paper . -- Christophe DUTANG Ph. D. student at ISFA [[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] the hat ^ in regular expression
Dear UseRs, I'm trying to find variable names (string after the "mydata$") in a expression. For example, myexpr <- expression( ( mydata$variable1 / mydata$variable2 ) ^ 2 - 1 + 3 * 4 ) I would like to get "variable1" and "variable2". The following few lines split the original character string into pieces. mystring <- as.character(myexpr) mydatapositions <- gregexpr("mydata", as.character(myexpr))[[1]] mydataend <- mydatapositions + attr(mydatapositions, "match.length") +1 mydatabegin <- c(mydatapositions, nchar(mystring)) In this loop, I try to remove operator signs, spaces and brackets. But I could not match the hat ^ in the string. for(i in 1:length(mydatapositions )) { nomydata <- substr(mystring, mydataend[i], mydatabegin[i+1]-1) nomydata <- gsub("\ ","",nomydata) print(nomydata) cat("_\n") res <- gregexpr("[+]",nomydata) print(c(gsub("[+]","",nomydata), unlist(res))) res <- gregexpr("[-]",nomydata) print(c(gsub("[-]","",nomydata), unlist(res))) res <- gregexpr("[/]",nomydata) print(c(gsub("[/]","",nomydata), unlist(res))) res <- gregexpr("[/]",nomydata) print(c(gsub("[*]","",nomydata), unlist(res))) res <- gregexpr(")",nomydata) print(c(gsub(")","",nomydata), unlist(res))) res <- gregexpr("\^",nomydata) print(c(gsub("\^","",nomydata), unlist(res))) print(gsub("[0-9]","",nomydata)) cat("-\n") } I get the following warnings telling me the character is not recognized but I don't know how to solve the problem... Warning messages: 1: '\^' is an unrecognized escape in a character string 2: unrecognized escape removed from "\^" 3: '\^' is an unrecognized escape in a character string 4: unrecognized escape removed from "\^" Any help is welcome. Christophe -- Christophe DUTANG Ph. D. student at ISFA [[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] [R-pkgs] new version of randtoolbox
Dear useRs, We are happy to announce a new version of the randtoolbox* package (version 1.09) on CRAN. The package is dedicated to Random Number Generation and in a less exhaustive way to RNG tests. The package is source-controlled at r-forge as part of the Rmetrics project http://r-forge.r-project.org/projects/rmetrics/ . We invite you to take a look at the NEWS section to know the latest development http://cran.r-project.org/web/packages/randtoolbox/NEWS . Christophe Dutang and Petr Savicky * for a license issue, the package has been splitted into 2 packages: randtoolbox and rngWELL. -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.fr [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] AR(2) modelling
Hi useRs, I'm trying to fit a basic AR(2) model with the 'ar' function. And when I try to check the value of the coefficients, I could not find the same value as the 'ar' function. Here is my example: myserie <- c(212, 205, 210, 213, 217, 222, 216, 218, 220, 212, 215, 236) #plot(myserie, type="l") myserieminus0 <- tail(myserie, -2) myserieminus1 <- tail(head(myserie, -1), -1) myserieminus2 <- head(myserie, -2) ###Yule Walker equations r1 <- cor(myserieminus0, myserieminus1) r2 <- cor(myserieminus0, myserieminus2) #method 1 phihat1 <- r1*(1-r2)/(1-r1^2) phihat2 <- (r2-r1^2)/(1-r1^2) #method 2 bigR <- cbind(c(1, r1), c(r1, 1)) smallr <- c(r1, r2) ressolve <- solve(bigR, smallr) resaryw <- ar(myserie, method="yule-walker", order.max=2, aic=FALSE) cat("\t\tmanual YW 1\t\tmanual YW 2\t\tar YW\n") cat("first coef", phihat1,"\t", ressolve[1],"\t\t", resaryw$ar[1], "\n") cat("first coef", phihat2,"\t", ressolve[2],"\t", resaryw$ar[2], "\n\n") >manual YW 1 manual YW 2 ar YW > first coef 0.29418080.2941808 0.1869641 > first coef -0.1316839 -0.1316839 -0.1038001 I do not understand why the "yule-walker" does not solve exactly the Yule-Walker equations. A reference can be found here http://www-stat.wharton.upenn.edu/~steele/Courses/956/ResourceDetails/YWSourceFiles/YW-Eshel.pdf . In the R source code (/src/library/stats/R), the file ar.R contains the ar.yw.default function implements the function. For univariate case (line 130), r_eureka function is used, which seems to be implemented in the eureka.f function. subroutine eureka (lr,r,g,f,var,a) c c solves Toeplitz matrix equation toep(r)f=g(1+.) c by Levinson's algorithm c a is a workspace of size lr, the number c of equations c is supposed to implement the Yule-Walker equations... Any help is welcome. Just to be sure, I can do something I try to reconcile the ordinary least square methods. And it works! Christophe PS : OLS code ###Ordinary Least Square reslm <- lm(myserieminus0 ~ myserieminus1 + myserieminus2) #summary(reslm) coef1ols <- reslm$coefficients["myserieminus1"] coef2ols <- reslm$coefficients["myserieminus2"] resarols <- ar(myserie, method="ols", order.max=2, aic=FALSE) cat("\t\tmanual ols\t\tar ols\n") cat("first coef", coef1ols,"\t", resarols$ar[1], "\n") cat("first coef", coef2ols,"\t", resarols$ar[2], "\n\n") -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.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] [R-SIG-Finance] Fast optimizer
Le 30 oct. 2009 à 02:21, R_help Help a écrit : Ok. I have the following likelihood function. L <- p*dpois(x,a)*dpois(y,b+c)+(1-p)*dpois(x,a+c)*dpois(y,b) where I have 100 points of (x,y) and parameters c(a,b,c,p) to estimate. Constraints are: 0 < p < 1 a,b,c > 0 c < a c < b I construct a loglikelihood function out of this. First ignoring the last two constraints, it takes optim with box constraint about 1-2 min to estimate this. I have to estimate the MLE on about 200 rolling windows. This will take very long. Is there any faster implementation? Take a look at the CRAN task view on optimisation, you may find faster algorithms. Secondly, I cannot incorporate the last two contraints using optim function. you can test the trick Ltilde <- function(a,b,c,p) ifelse( c < a & c < b, p*dpois(x,a)*dpois (y,b+c)+(1-p)*dpois(x,a+c)*dpois(y,b), -10^6) Christophe Thank you, rc On Thu, Oct 29, 2009 at 9:02 PM, Ravi Varadhan wrote: You have hardly given us any information for us to be able to help you. Give us more information on your problem, and, if possible, a minimal, self-contained example of what you are trying to do. Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: R_help Help Date: Thursday, October 29, 2009 8:24 pm Subject: [R] Fast optimizer To: r-help@r-project.org, r-sig-fina...@stat.math.ethz.ch Hi, I'm using optim with box constraints to MLE on about 100 data points. It goes quite slow even on 4GB machine. I'm wondering if R has any faster implementation? Also, if I'd like to impose equality/nonequality constraints on parameters, which package I should use? Any help would be appreciated. Thank you. rc __ R-help@r-project.org mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. ___ r-sig-fina...@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first. -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.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] attach
Hi all, I have a question regarding the memory usage for the attach function. Say I have a data.frame inputdat that I create with read.csv. I would like to know what happens on the memory side when I use attach(inputdata) Is there a second allocation of memory for inputdata? Then I'm using eval on a expression which depends on the columns of inputdata. Is it better not to use attach function? Thanks in advance Christophe -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.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] windows system file aux
Hi all, I just would like to notice a small problem of R on windows (XP at least). If you execute the following lines x <- rexp(1000) write.csv(x, file="aux.csv") the R GUI just loops for ever... this is due to the fact on windows, users can create a file or directory with the name aux or aux.*. If you try to create a text file on windows aux.txt, it says you could not do it. Is it possible for the R GUI to catch this message? or just raise an error? Thanks in advance Christophe -- Christophe DUTANG Ph. D. student at ISFA [[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] try function
Hi all, I'm using the try function for data import with read.csv function. I would like to know if there is a double allocation of memory when using this code test.t <- try(input1 <- read.csv("myfile.csv") ) compared to this one test.t <- try( read.csv("myfile.csv") ) I think for the first code, both test.t and input1 have the input data (when no error is raised). So I use twice the memory for the same dataset. But I look at the RAM memory used by R for these two code (in windows XP with process explorer), the first code seems to use less memory... which is counter intuitive. what is the truth? Thanks in advance Christophe PS : I'm using R 2.9.2 on win XP -- Christophe DUTANG Ph. D. student at ISFA [[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] Fwd: generic methods - in particular the summary function
Thanks for your answer. Yes, I use now a proper NAMESPACE with function declared correctly. Christophe Le 27 sept. 2009 à 19:16, David Winsemius a écrit : On Sep 27, 2009, at 12:52 PM, Christophe Dutang wrote: Nobody wants to answer my question... is there something stupid in it? I couldn't really say. Not being a user of fitdistrplus I don't have much baseline experience. Had you posted code that produced something to work on, I might have made an effort at applying the methods I typically use, such as str(), methods(), and printing out the function code. But I am a rather low-level R- user, and as soon as you strart throwing around questions about NAMESPACE, my eyes glaze over and I move to the next question. When I do install and load fitdistrplus and then execute: methods(summary) .. I see a new function which is not even invisible, called summary.fitdist. So it seems to be in my NAMESPACE ... or at least what I dimly understand about such metaphysical entities. I get an error when I execute your suggestion: > S3method(summary, fitdist) Error: could not find function "S3method" So I would have assumed that you had a package with that "S3method" function about which you had not informed us. Not sure this helps because, as I said, your question appeared more complex that I considered myself competent to answer. -- David Début du message réexpédié : De : Christophe Dutang Date : 19 septembre 2009 11:26:51 HAEC À : r-help@r-project.org Objet : generic methods - in particular the summary function Hi all, I'm currently working on the fitdistrplus package (that basically fit distributions). There is something I do not understand about the generic function summary. In the current version on CRAN, there is no NAMESPACE saying S3method(summary, fitdist) . However if we use summary on an object send by fitdist function it works fine... According to R-lang, we have " The most common use of generic functions is to provide print and summary methods for statistical ob jects, generally the output of some model fitting process. To do this, each model attaches a class attribute to its output and then provides a special method that takes that output and provides a nice readable version of it. The user then needs only remember that print or summary will provide nice output for the results of any analysis. " I would like to be sure, that if the summary.fitdist is not exported in the NAMESPACE, then we must use declare it with S3method. Thanks in advance Christophe -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.fr -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.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. David Winsemius, MD Heritage Laboratories West Hartford, CT -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.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] Fwd: generic methods - in particular the summary function
Nobody wants to answer my question... is there something stupid in it? Début du message réexpédié : > De : Christophe Dutang > Date : 19 septembre 2009 11:26:51 HAEC > À : r-help@r-project.org > Objet : generic methods - in particular the summary function > > Hi all, > > I'm currently working on the fitdistrplus package (that basically > fit distributions). There is something I do not understand about the > generic function summary. > > In the current version on CRAN, there is no NAMESPACE saying > > S3method(summary, fitdist) > > . > However if we use summary on an object send by fitdist function it > works fine... > > According to R-lang, we have > " > The most common use of generic functions is to provide print and > summary methods for > statistical ob jects, generally the output of some model fitting > process. To do this, each model > attaches a class attribute to its output and then provides a special > method that takes that output > and provides a nice readable version of it. The user then needs only > remember that print or > summary will provide nice output for the results of any analysis. > " > > I would like to be sure, that if the summary.fitdist is not exported > in the NAMESPACE, then we must use declare it with S3method. > > Thanks in advance > > Christophe > > -- > Christophe Dutang > Ph.D. student at ISFA, Lyon, France > website: http://dutangc.free.fr > -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.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] generic methods - in particular the summary function
Hi all, I'm currently working on the fitdistrplus package (that basically fit distributions). There is something I do not understand about the generic function summary. In the current version on CRAN, there is no NAMESPACE saying S3method(summary, fitdist) . However if we use summary on an object send by fitdist function it works fine... According to R-lang, we have " The most common use of generic functions is to provide print and summary methods for statistical ob jects, generally the output of some model fitting process. To do this, each model attaches a class attribute to its output and then provides a special method that takes that output and provides a nice readable version of it. The user then needs only remember that print or summary will provide nice output for the results of any analysis. " I would like to be sure, that if the summary.fitdist is not exported in the NAMESPACE, then we must use declare it with S3method. Thanks in advance Christophe -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.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] thousands separator
thanks, I test it on the following example 27 076 552 440.95,230 400.04,1 27 176 285 276.98,170 240.22,1 27 276 040 780.57,640 053.22,1 27 376 072 983.53,800 300.1,1 27 476 552 531.87,411 770.68,1 27 576 552 919.09,130 010.21,1 27 676 285 254.43,460 020.70,1 27 776 072 840.44,220 071.16,1 27 876 032 704.00,540 121.14,1 setwd("~/Desktop") x <- read.table("untitled", as.is=TRUE, sep=",") col2cvt <- c('V1', 'V2','V3') for(i in col2cvt) { x[[i]] <- as.numeric(gsub(" ","",x[[i]])) } print(x,digits=22) it works fine! Christophe Le 21 juil. 09 à 21:47, jim holtman a écrit : > What I do is read the file in and then convert the various columns > to numeric > > x <- read.table(..., as.is=TRUE) > col2cvt <- c('V1', 'V3','V6') # columns for conversion > for (i in col2cvt){ > x[[i]] <- as.numeric(gsub(",", "", x[[i]])) > } > > Replace ',' with ' ' for blanks. > > On Tue, Jul 21, 2009 at 3:34 PM, christophe > dutang wrote: >> Dear useRs, >> >> I was wondering how to deal with data where thousands separator is >> a space >> or a comma? with google, I thought I found the answer but the >> thread ( >> http://tolstoy.newcastle.edu.au/R/help/06/04/25524.html) just >> focuses on >> decimal separator. >> >> Is there any function to numbers written like this in a csv file? >> >> Thanks in advance >> >> Christophe >> >> -- >> Christophe DUTANG >> Ph. D. student at ISFA >> >>[[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. >> > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 > > What is the problem that you are trying to solve? -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.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] thousands separator
Dear useRs, I was wondering how to deal with data where thousands separator is a space or a comma? with google, I thought I found the answer but the thread ( http://tolstoy.newcastle.edu.au/R/help/06/04/25524.html) just focuses on decimal separator. Is there any function to numbers written like this in a csv file? Thanks in advance Christophe -- Christophe DUTANG Ph. D. student at ISFA [[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] drawing arrows
Thanks, I'll take a look. Christophe Le 15 mai 09 à 20:11, Greg Snow a écrit : > Duncan mentioned the arrows function, which may do everything you > want. But, also look at the my.symbols function in the > TeachingDemos package for another way to draw arrows, or to draw > your circles and arrows in 1 step. > > -- > Gregory (Greg) L. Snow Ph.D. > Statistical Data Center > Intermountain Healthcare > greg.s...@imail.org > 801.408.8111 > > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- >> project.org] On Behalf Of christophe dutang >> Sent: Friday, May 15, 2009 10:44 AM >> To: r-help@r-project.org >> Subject: [R] drawing arrows >> >> Hi, >> >> I would like to draw arrows in a classic 2D plot. Which package >> should >> I >> use? is there R base functions that do job? >> >> On google, I could not find any useful discussion about this topic, >> except a >> link to the function 'grid.arrows' of the grid package. >> >> My problem is I would like to draw arrows at the edge of circles >> drawn >> by >> the 'symbols' function. Maybe there is already a dedicated function >> for >> this? >> >> Any help is appreciated. >> >> Christophe >> >> >> >> -- >> Christophe DUTANG >> Ph. D. student at ISFA >> >> [[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. Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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] drawing arrows
Hi, I would like to draw arrows in a classic 2D plot. Which package should I use? is there R base functions that do job? On google, I could not find any useful discussion about this topic, except a link to the function 'grid.arrows' of the grid package. My problem is I would like to draw arrows at the edge of circles drawn by the 'symbols' function. Maybe there is already a dedicated function for this? Any help is appreciated. Christophe -- Christophe DUTANG Ph. D. student at ISFA [[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] legend with small colored boxes
I thought I have tried to pass a vector of "colors" and that it did not work.. Thanks for all! Christophe Le 29 avr. 09 à 12:16, Jim Lemon a écrit : Christophe Dutang wrote: Hi all, I tried to a nice legend with small boxes filled with the colors used for the plots. But it does nor work, boxes are always filled with black. An example is here plot(1:4,1:4) lines(1:4,4:1, col="blue") legend("top",leg=c("a","b"),col=c("black","blue"), fill=TRUE) How could I specify the colors? the argument col.box is the color of the whole legend box... Ah Cristophe, you have been waylaid by the coercion of types. The fill argument specifies the colors of the boxes, and you have sent it TRUE. As TRUE happens to be equal to 1, legend is fooled into filling the boxes with the color assigned the number 1, which is black. Try: legend(...,fill=c("black","blue"),...) Jim -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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] legend with small colored boxes
Hi all, I tried to a nice legend with small boxes filled with the colors used for the plots. But it does nor work, boxes are always filled with black. An example is here plot(1:4,1:4) lines(1:4,4:1, col="blue") legend("top",leg=c("a","b"),col=c("black","blue"), fill=TRUE) How could I specify the colors? the argument col.box is the color of the whole legend box... Thanks in advance Christophe PS : I work with R 2.9.0. -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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] problem with symbol function
Based on your solution, could we not fix this issue for the symbol function? Le 27 avr. 09 à 23:47, Duncan Murdoch a écrit : On 27/04/2009 5:23 PM, Christophe Dutang wrote: so it could be a limitation of graphics on windows? It's not graphics on Windows, but it appears to be a limitation of the windows() graphics device in R. It is used for bitmap plots as well as on-screen plots, which is why you saw the same effect in jpeg, but different devices are used for Postscript and PDF. When drawing lines, R handles the dash style itself, rather than using the built-in dashes. But it doesn't do so for circles, and doesn't make use of the Windows line styles. If you really need the dashes onscreen, you can draw the circle yourself. Assuming the scales are equal on both axes that's easy, just use > theta <- seq(0,2*pi, len=256) > lines(x+r*cos(theta), y+r*sin(theta), lty="dashed") (where (x,y) is the center and r is the radius). It's more work if you want things to appear as circles when the scales are unequal, but I think this works: circle <- function(x, y, inches=1, ...) { theta <- seq(0, 2*pi, len=256) lines(x + grconvertX(inches*cos(theta), "inches", "user") - grconvertX(0, "inches", "user"), y + grconvertY(inches*sin(theta), "inches", "user") - grconvertY(0, "inches", "user"), ...) } so you'd get the plot you wanted using circle(0, 0, inches = 1.5, fg="black",lty="dashed") The circle function is not vectorized, so it's not as useful as symbols, but it could be improved. Duncan Murdoch It also appears with "long dash" lines. x <- -4:4 y <- -4:4 plot(x,y,type="n") symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black", lty="solid") symbols(0, 0, add = TRUE, circles = 1, inches = 2, fg="black",lty="dashed") symbols(0, 0, add = TRUE, circles = 1, inches = 3, fg="black",lty="longdash", lwd=2) Le 27 avr. 09 à 23:07, Joshua Wiley a écrit : I read that the lty=2 argument does not work on all graphics devices. You might double check that since it works on mac. Joshua Wiley Original message Date: Mon, 27 Apr 2009 22:58:11 +0200 From: Christophe Dutang Subject: Re: [R] problem with symbol function To: Joshua Wiley Cc: r-help@r-project.org This point is ok if I download R from the Austrian mirror. R is properly install on both computers. I also get this strange behavior with R 2.7.2. There is something I'm missing... Le 27 avr. 09 à 22:54, Joshua Wiley a écrit : I am running SP3. You said earlier that you were having trouble downloading 2.9.0, are you sure everything downloaded and installed properly? There have been some questions about transitioning to the new build going around. Joshua Wiley Original message Date: Mon, 27 Apr 2009 22:45:26 +0200 From: Christophe Dutang Subject: Re: [R] problem with symbol function To: Joshua Wiley Cc: r-help@r-project.org what is your service pack version? at home I use the SP2 version. Le 27 avr. 09 à 22:29, Joshua Wiley a écrit : Hi Christophe, I am able to plot dashed circles on Windows. I'm afraid I do not have any suggestions for you. What happens when you try to plot it on Windows? Joshua Wiley Original message Date: Mon, 27 Apr 2009 22:15:53 +0200 From: r-help-boun...@r-project.org (on behalf of Christophe Dutang ) Subject: [R] problem with symbol function To: r-help@r-project.org Hi all, I use the symbol functions to draw circles. But the argument lty does not work on windows but works correctly on my macbook: x <- -4:4 y <- -4:4 plot(x,y,type="n") symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black", lty="solid") symbols(0, 0, add = TRUE, circles = 1, inches = 2, fg="black", lty="dashed") The second circle should be drawn with dash... it works on my macbook but on my PC. I use R 2.9.0 on windows xp home and mac os 10.5. Does anyone have this problem? is it a limitation of windows? thanks in advance Christophe -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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. -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.fr -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.fr -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutan
Re: [R] downloading r 2.9.0
with the Austrian, it works fine... I should have think before sending an email to r help.. Thanks 2009/4/28 Paul Hiemstra > christophe dutang wrote: > >> Hi all, >> >> I try to download R 2.9.0 from French mirrors... but the download stops >> mysteriously at 13.2 MB of the 65MB file. I get this both on my mac and my >> PC... >> >> does anyone face this problem? >> >> Christophe >> >> >> > Try a different mirror and see what that does > Paul > > -- > Drs. Paul Hiemstra > Department of Physical Geography > Faculty of Geosciences > University of Utrecht > Heidelberglaan 2 > P.O. Box 80.115 > 3508 TC Utrecht > Phone: +3130 274 3113 Mon-Tue > Phone: +3130 253 5773 Wed-Fri > http://intamap.geo.uu.nl/~paul <http://intamap.geo.uu.nl/%7Epaul> > > -- Christophe DUTANG Ph. D. student at ISFA [[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] problem with symbol function
ok, I'll try to use to your code or use pdf files. Thanks for all Christophe Le 28 avr. 09 à 01:38, Joshua Wiley a écrit : My apologies; I did not use exactly his code. I usually plot directly to postscript files. Since when I manipulated the lty argument, I got the expected results (via postscript), everything seemed in order. It never occurred to me that postscript would not give me the same view. I am very sorry for the inconvenience. Joshua Wiley Original message Date: Mon, 27 Apr 2009 17:12:18 -0400 From: Duncan Murdoch Subject: Re: [R] problem with symbol function To: Joshua Wiley Cc: r-help@r-project.org, Christophe Dutang On 27/04/2009 4:29 PM, Joshua Wiley wrote: Hi Christophe, I am able to plot dashed circles on Windows. I'm afraid I do not have any suggestions for you. What happens when you try to plot it on Windows? Were you using the same code as Christophe? I see what he saw: the circle comes out with a solid line. Duncan Murdoch Joshua Wiley Original message Date: Mon, 27 Apr 2009 22:15:53 +0200 From: r-help-boun...@r-project.org (on behalf of Christophe Dutang ) Subject: [R] problem with symbol function To: r-help@r-project.org Hi all, I use the symbol functions to draw circles. But the argument lty does not work on windows but works correctly on my macbook: x <- -4:4 y <- -4:4 plot(x,y,type="n") symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black", lty="solid") symbols(0, 0, add = TRUE, circles = 1, inches = 2, fg="black", lty="dashed") The second circle should be drawn with dash... it works on my macbook but on my PC. I use R 2.9.0 on windows xp home and mac os 10.5. Does anyone have this problem? is it a limitation of windows? thanks in advance Christophe -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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. -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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] problem with symbol function
so it could be a limitation of graphics on windows? It also appears with "long dash" lines. x <- -4:4 y <- -4:4 plot(x,y,type="n") symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black", lty="solid") symbols(0, 0, add = TRUE, circles = 1, inches = 2, fg="black",lty="dashed") symbols(0, 0, add = TRUE, circles = 1, inches = 3, fg="black",lty="longdash", lwd=2) Le 27 avr. 09 à 23:07, Joshua Wiley a écrit : > I read that the lty=2 argument does not work on all graphics > devices. You might double check that since it works on mac. > > > Joshua Wiley > > > > Original message >> Date: Mon, 27 Apr 2009 22:58:11 +0200 >> From: Christophe Dutang >> Subject: Re: [R] problem with symbol function >> To: Joshua Wiley >> Cc: r-help@r-project.org >> >> This point is ok if I download R from the Austrian mirror. R is >> properly install on both computers. I also get this strange behavior >> with R 2.7.2. There is something I'm missing... >> >> >> Le 27 avr. 09 à 22:54, Joshua Wiley a écrit : >> >>> I am running SP3. You said earlier that you were having trouble >>> downloading 2.9.0, are you sure everything downloaded and installed >>> properly? There have been some questions about transitioning to the >>> new build going around. >>> >>> Joshua Wiley >>> >>> >>> >>> Original message >>>> Date: Mon, 27 Apr 2009 22:45:26 +0200 >>>> From: Christophe Dutang >>>> Subject: Re: [R] problem with symbol function >>>> To: Joshua Wiley >>>> Cc: r-help@r-project.org >>>> >>>> what is your service pack version? >>>> >>>> at home I use the SP2 version. >>>> >>>> Le 27 avr. 09 à 22:29, Joshua Wiley a écrit : >>>> >>>>> Hi Christophe, >>>>> >>>>> I am able to plot dashed circles on Windows. I'm afraid I do not >>>>> have any suggestions for you. What happens when you try to plot it >>>>> on Windows? >>>>> >>>>> >>>>> Joshua Wiley >>>>> >>>>> >>>>> Original message >>>>>> Date: Mon, 27 Apr 2009 22:15:53 +0200 >>>>>> From: r-help-boun...@r-project.org (on behalf of Christophe >>>>>> Dutang >>>>>> ) >>>>>> Subject: [R] problem with symbol function >>>>>> To: r-help@r-project.org >>>>>> >>>>>> Hi all, >>>>>> >>>>>> I use the symbol functions to draw circles. But the argument lty >>>>>> does >>>>>> not work on windows but works correctly on my macbook: >>>>>> >>>>>> x <- -4:4 >>>>>> y <- -4:4 >>>>>> >>>>>> plot(x,y,type="n") >>>>>> >>>>>> symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black", >>>>>> lty="solid") >>>>>> >>>>>> symbols(0, 0, add = TRUE, circles = 1, inches = 2, fg="black", >>>>>> lty="dashed") >>>>>> >>>>>> >>>>>> The second circle should be drawn with dash... it works on my >>>>>> macbook >>>>>> but on my PC. >>>>>> >>>>>> I use R 2.9.0 on windows xp home and mac os 10.5. >>>>>> >>>>>> Does anyone have this problem? is it a limitation of windows? >>>>>> >>>>>> thanks in advance >>>>>> >>>>>> >>>>>> Christophe >>>>>> >>>>>> -- >>>>>> Christophe Dutang >>>>>> Ph. D. student at ISFA, Lyon, France >>>>>> website: http://dutangc.free.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. >>>> >>>> -- >>>> Christophe Dutang >>>> Ph. D. student at ISFA, Lyon, France >>>> website: http://dutangc.free.fr >>>> >>>> >>>> >>>> >> >> -- >> Christophe Dutang >> Ph. D. student at ISFA, Lyon, France >> website: http://dutangc.free.fr >> >> >> >> -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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] problem with symbol function
Yes png or jpeg files do not work whereas pdfs are ok on windows... Le 27 avr. 09 à 22:59, Andrew Dolman a écrit : > I just tested this on my windows setup and you're right - it appears > to draw 2 solid circles and if you save as .png or .jpeg that's what > you get in the resultant file - but if you save as .ps or .pdf you > get a dashed outer circle. > > > I don't know why. > > Andy. R 2.8.1 > > > > andydol...@gmail.com > > > 2009/4/27 Christophe Dutang > what is your service pack version? > > at home I use the SP2 version. > > > Le 27 avr. 09 à 22:29, Joshua Wiley a écrit : > > Hi Christophe, > > I am able to plot dashed circles on Windows. I'm afraid I do not > have any suggestions for you. What happens when you try to plot it > on Windows? > > > Joshua Wiley > > > Original message > Date: Mon, 27 Apr 2009 22:15:53 +0200 > From: r-help-boun...@r-project.org (on behalf of Christophe Dutang > >) > Subject: [R] problem with symbol function > To: r-help@r-project.org > > Hi all, > > I use the symbol functions to draw circles. But the argument lty does > not work on windows but works correctly on my macbook: > > x <- -4:4 > y <- -4:4 > > plot(x,y,type="n") > > symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black", > lty="solid") > > symbols(0, 0, add = TRUE, circles = 1, inches = 2, fg="black", > lty="dashed") > > > The second circle should be drawn with dash... it works on my macbook > but on my PC. > > I use R 2.9.0 on windows xp home and mac os 10.5. > > Does anyone have this problem? is it a limitation of windows? > > thanks in advance > > > Christophe > > -- > Christophe Dutang > Ph. D. student at ISFA, Lyon, France > website: http://dutangc.free.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. > > -- > Christophe Dutang > Ph. D. student at ISFA, Lyon, France > website: http://dutangc.free.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. > -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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] problem with symbol function
This point is ok if I download R from the Austrian mirror. R is properly install on both computers. I also get this strange behavior with R 2.7.2. There is something I'm missing... Le 27 avr. 09 à 22:54, Joshua Wiley a écrit : I am running SP3. You said earlier that you were having trouble downloading 2.9.0, are you sure everything downloaded and installed properly? There have been some questions about transitioning to the new build going around. Joshua Wiley Original message Date: Mon, 27 Apr 2009 22:45:26 +0200 From: Christophe Dutang Subject: Re: [R] problem with symbol function To: Joshua Wiley Cc: r-help@r-project.org what is your service pack version? at home I use the SP2 version. Le 27 avr. 09 à 22:29, Joshua Wiley a écrit : Hi Christophe, I am able to plot dashed circles on Windows. I'm afraid I do not have any suggestions for you. What happens when you try to plot it on Windows? Joshua Wiley Original message Date: Mon, 27 Apr 2009 22:15:53 +0200 From: r-help-boun...@r-project.org (on behalf of Christophe Dutang ) Subject: [R] problem with symbol function To: r-help@r-project.org Hi all, I use the symbol functions to draw circles. But the argument lty does not work on windows but works correctly on my macbook: x <- -4:4 y <- -4:4 plot(x,y,type="n") symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black", lty="solid") symbols(0, 0, add = TRUE, circles = 1, inches = 2, fg="black", lty="dashed") The second circle should be drawn with dash... it works on my macbook but on my PC. I use R 2.9.0 on windows xp home and mac os 10.5. Does anyone have this problem? is it a limitation of windows? thanks in advance Christophe -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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. -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.fr -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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] problem with symbol function
what is your service pack version? at home I use the SP2 version. Le 27 avr. 09 à 22:29, Joshua Wiley a écrit : Hi Christophe, I am able to plot dashed circles on Windows. I'm afraid I do not have any suggestions for you. What happens when you try to plot it on Windows? Joshua Wiley Original message Date: Mon, 27 Apr 2009 22:15:53 +0200 From: r-help-boun...@r-project.org (on behalf of Christophe Dutang >) Subject: [R] problem with symbol function To: r-help@r-project.org Hi all, I use the symbol functions to draw circles. But the argument lty does not work on windows but works correctly on my macbook: x <- -4:4 y <- -4:4 plot(x,y,type="n") symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black", lty="solid") symbols(0, 0, add = TRUE, circles = 1, inches = 2, fg="black", lty="dashed") The second circle should be drawn with dash... it works on my macbook but on my PC. I use R 2.9.0 on windows xp home and mac os 10.5. Does anyone have this problem? is it a limitation of windows? thanks in advance Christophe -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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. -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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] problem with symbol function
it just plot solid lines? I also have a similar problem on my PC at the office, which run XP pro... Le 27 avr. 09 à 22:29, Joshua Wiley a écrit : Hi Christophe, I am able to plot dashed circles on Windows. I'm afraid I do not have any suggestions for you. What happens when you try to plot it on Windows? Joshua Wiley Original message Date: Mon, 27 Apr 2009 22:15:53 +0200 From: r-help-boun...@r-project.org (on behalf of Christophe Dutang >) Subject: [R] problem with symbol function To: r-help@r-project.org Hi all, I use the symbol functions to draw circles. But the argument lty does not work on windows but works correctly on my macbook: x <- -4:4 y <- -4:4 plot(x,y,type="n") symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black", lty="solid") symbols(0, 0, add = TRUE, circles = 1, inches = 2, fg="black", lty="dashed") The second circle should be drawn with dash... it works on my macbook but on my PC. I use R 2.9.0 on windows xp home and mac os 10.5. Does anyone have this problem? is it a limitation of windows? thanks in advance Christophe -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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. -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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] problem with symbol function
Hi all, I use the symbol functions to draw circles. But the argument lty does not work on windows but works correctly on my macbook: x <- -4:4 y <- -4:4 plot(x,y,type="n") symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black", lty="solid") symbols(0, 0, add = TRUE, circles = 1, inches = 2, fg="black", lty="dashed") The second circle should be drawn with dash... it works on my macbook but on my PC. I use R 2.9.0 on windows xp home and mac os 10.5. Does anyone have this problem? is it a limitation of windows? thanks in advance Christophe -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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] downloading r 2.9.0
Hi all, I try to download R 2.9.0 from French mirrors... but the download stops mysteriously at 13.2 MB of the 65MB file. I get this both on my mac and my PC... does anyone face this problem? Christophe -- Christophe DUTANG Ph. D. student at ISFA [[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] plot with 2 y axes
Hi all, I would like to know how to do a plot with 2 y axes in R. With google, I found this topic has been discussed twice in the past: - http://tolstoy.newcastle.edu.au/R/e2/help/06/11/6049.html - https://stat.ethz.ch/pipermail/r-help/2000-September/008182.html Those links provide quite a good solution, but I wonder if there exists an easier solution to plot two series that have units in R? or in a contributed packages? Thanks in advance Christophe -- Christophe Dutang Ph. D. student at ISFA, Lyon, France website: http://dutangc.free.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] date operations
Thanks a lot Envoyé de mon iPhone Le 3 déc. 08 à 00:39, "jim holtman" <[EMAIL PROTECTED]> a écrit : If you want to do the addition, 'unclass' the variable: alpha2+4 [1] "2008-12-25" alpha2 + unclass(alpha1) [1] "2009-02-15" On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang <[EMAIL PROTECTED]> wrote: Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods ("+.Date", "Ops.difftime") for "+" I saw this topic in this mailing list, but I do not understand what to do... cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html Do I have to convert Dates to numeric? Thanks in advance Christophe PS : R script used alpha2=as.Date("2008-12-21") alpha1=as.Date("2008-12-21")-as.Date("2008-10-26") alpha1 alpha2 alpha1+alpha2 [[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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] date operations
Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods ("+.Date", "Ops.difftime") for "+" I saw this topic in this mailing list, but I do not understand what to do... cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html Do I have to convert Dates to numeric? Thanks in advance Christophe PS : R script used alpha2=as.Date("2008-12-21") alpha1=as.Date("2008-12-21")-as.Date("2008-10-26") alpha1 alpha2 alpha1+alpha2 [[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] cran task view on probability distributions
Dear R users, From today, you can find a cran task view on probability distributions I maintain cf. http://cran.r-project.org/web/views/Distributions.html . The Devel version can be found on R-forge along with other CTVs (cf. http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/inst/ctv/?root=ctv ). Any remarks, suggestions and comments are welcome, especially those of package maintainers. Kind regards Christophe Dutang __ 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] package building problem on windows
Actually I was suspected that 'r cmd build' search for 'C:/DOCUME~1/c- dutang/Local' and not 'C:/DOCUME~1/c-dutang/Local Settings'. I will check (tomorrow) if there are any spaces in environment variables TMP*. Thanks for your suggestion. Christophe Le 17 août 08 à 14:08, Prof Brian Ripley a écrit : Does your setting of TMPDIR, TEMP or TMP have a space in it? From the R-admin manual: You may need to set TMPDIR to the absolute path to a suitable temporary directory: the default is 'c:/TEMP'. (Use forward slashes and do not use a path including spaces.) The documentation is that manual, not 'Murdoch's page', whatever that is. On Sun, 17 Aug 2008, Christophe Dutang wrote: Hi, I'm trying to compile the package biglm, but when I build it with R CMD build biglm, it failed : C:\LOCAL\c-dutang\code\R\biglm2>R CMD build biglm * checking for file 'biglm/DESCRIPTION' ... OK * preparing 'biglm': * checking DESCRIPTION meta-information ...C:/DOCUME~1/c-dutang/ Local: Can't op n C:/DOCUME~1/c-dutang/Local: No such file or directory C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory OK * cleaning src * removing junk files C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory Error: cannot open file 'biglm/DESCRIPTION' for reading But when I install it, the installation is performed but I still have 'can't open' and 'no such file or directory'. C:\LOCAL\c-dutang\code\R\biglm2>R CMD install biglm C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory installing to '' -- Making package biglm adding build stamp to DESCRIPTION installing NAMESPACE file and metadata making DLL ... gcc -std=gnu99 -IC:/PROGRA~1/R/R-2.7.1/include -O3 -Wall -c boundedQR.c - o boundedQR.o gfortran -O3 -c boundedQRf.f -o boundedQRf.o windres --preprocessor="gcc -E -xc -DRC_INVOKED" -I C:/PROGRA~1/R/ R-2.7.1/includ e -i biglm_res.rc -o biglm_res.o gcc -std=gnu99 -shared -s -o biglm.dll biglm.def boundedQR.o boundedQRf.o big lm_res.o -LC:/PROGRA~1/R/R-2.7.1/bin -lgfortran -lR ... DLL made installing DLL installing R files installing man source files installing indices installing help Building/Updating help pages for package 'biglm' Formats: text html latex example chm adding MD5 sums * DONE (biglm) Actually, I have no directory local in 'document and settings' but a directory local settings exists. What's wrong with my installation? I install all tools as recommanded on Murdoch's page. Maybe R CMD build tries to use a temp file? in 'document and settings'? I use R 2.7.1 with Windows xp pro. Thanks in advance Christophe __ 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. -- Brian D. Ripley, [EMAIL PROTECTED] 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.
[R] package building problem on windows
Hi, I'm trying to compile the package biglm, but when I build it with R CMD build biglm, it failed : C:\LOCAL\c-dutang\code\R\biglm2>R CMD build biglm * checking for file 'biglm/DESCRIPTION' ... OK * preparing 'biglm': * checking DESCRIPTION meta-information ...C:/DOCUME~1/c-dutang/Local: Can't op n C:/DOCUME~1/c-dutang/Local: No such file or directory C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory OK * cleaning src * removing junk files C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory Error: cannot open file 'biglm/DESCRIPTION' for reading But when I install it, the installation is performed but I still have 'can't open' and 'no such file or directory'. C:\LOCAL\c-dutang\code\R\biglm2>R CMD install biglm C:/DOCUME~1/c-dutang/Local: Can't open C:/DOCUME~1/c-dutang/Local: No such file or directory installing to '' -- Making package biglm adding build stamp to DESCRIPTION installing NAMESPACE file and metadata making DLL ... gcc -std=gnu99 -IC:/PROGRA~1/R/R-2.7.1/include -O3 -Wall -c boundedQR.c - o boundedQR.o gfortran -O3 -c boundedQRf.f -o boundedQRf.o windres --preprocessor="gcc -E -xc -DRC_INVOKED" -I C:/PROGRA~1/R/ R-2.7.1/includ e -i biglm_res.rc -o biglm_res.o gcc -std=gnu99 -shared -s -o biglm.dll biglm.def boundedQR.o boundedQRf.o big lm_res.o -LC:/PROGRA~1/R/R-2.7.1/bin -lgfortran -lR ... DLL made installing DLL installing R files installing man source files installing indices installing help >>> Building/Updating help pages for package 'biglm' Formats: text html latex example chm adding MD5 sums * DONE (biglm) Actually, I have no directory local in 'document and settings' but a directory local settings exists. What's wrong with my installation? I install all tools as recommanded on Murdoch's page. Maybe R CMD build tries to use a temp file? in 'document and settings'? I use R 2.7.1 with Windows xp pro. Thanks in advance Christophe __ 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] aligned memory allocation in C
Yes, it seems a good idea but your two questions are also good questions! Le 13 août 08 à 04:52, Jeffrey Horner a écrit : Christophe Dutang1 wrote: Hi, I'm currently R porting SF Mersenne Twister algorithm of Matsumoto and Saito. To get the full power of their code, I want to use their fonction fill_array32 which need aligned memory. That is to say I need to use the C function memalign on windows, posix_memalign on linux and classic malloc on Mac OS. In 'writing R extenstion', they recommand to use R_alloc function to allocate memory in C. Does R_alloc return a pointer to aligned memory? if not how can I do this? probably no, because R crashes when I succesively R_alloc and fill_array32 (cf below) on my macbook with R 2.7.1. You can still do this. Just take the address returned from R_alloc and test for alignment. If it's not, then just use an aligned address beyond the one returned. (But then the question is, which direction beyond the one returned? How does one test for that?) Jeff Thanks in advance Kind regards Christophe PS : http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/howto-compile.html provides an example of memalign. PPS : mac os report Thread 0 Crashed: 0 libSystem.B.dylib 0x9341bb9e __kill + 10 1 libSystem.B.dylib 0x93492ec2 raise + 26 2 libSystem.B.dylib 0x934a247f abort + 73 3 randtoolbox.so0x15e65f1d 0x15e5d000 + 36637 4 randtoolbox.so0x15e614ef fill_array32 + 4038 5 randtoolbox.so0x15e6513d SFmersennetwister + 335 6 randtoolbox.so0x15e652c6 doSFMersenneTwister + 255 7 libR.dylib0x00367a52 do_dotcall + 1394 8 libR.dylib0x0038b5a2 Rf_eval + 1754 9 libR.dylib0x0038f9a2 do_set + 592 10 libR.dylib0x0038b366 Rf_eval + 1182 11 libR.dylib0x0038b366 Rf_eval + 1182 12 libR.dylib0x0038c140 do_begin + 58 13 libR.dylib0x0038b366 Rf_eval + 1182 14 libR.dylib0x0038b366 Rf_eval + 1182 15 libR.dylib0x0038c140 do_begin + 58 16 libR.dylib0x0038b366 Rf_eval + 1182 17 libR.dylib0x0038d9a6 Rf_applyClosure + 663 18 libR.dylib0x0038b25d Rf_eval + 917 19 org.R-project.R 0x000189c3 run_REngineRmainloop + 569 (Rinit.m:442) 20 org.R-project.R 0x0001142a -[REngine runREPL] + 260 (REngine.m:181) 21 org.R-project.R 0x2e91 main + 795 (main.m: 126) 22 org.R-project.R 0x2b5a _start + 216 23 org.R-project.R 0x2a81 start + 41 __ 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://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] system time - windows specific problem
Firstly thank you for answering so quickly. I hope I used the good mailing list! Secondly, I check that I make call to the 'randomize' function. anyway, I will look more closely to the R source and also try QueryPerformanceCounter. Thirdly, maybe I will remove time machine for quasi random generation and use it only for pseudo random generation as in Rmetric packages. (but the problem with the seed still persists). Thanks again. Christophe Le 19 juil. 08 à 12:32, Duncan Murdoch a écrit : On 18/07/2008 5:26 PM, Christophe Dutang wrote: Hi all, I'm currently implementing quasi random generation (torus) on R (package randtoolbox available on CRAN). Even if it is not a great idea, I decided to use the machine time to initiate the seed. So when the seed is not specified by the user, the pkg uses the time machine time. Hence the following R code should produce different uniform variates : > for(i in 1:10)print(torus(1)) But on windows, I get : > library(randtoolbox) > for(i in 1:10)print(torus(1)) [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 > while on mac os, we get : > library(randtoolbox) > for(i in 1:10)print(torus(1)) [1] 0.9730577 [1] 0.9124289 [1] 0.5123534 [1] 0.4640765 [1] 0.9367557 [1] 0.2945414 [1] 0.3671455 [1] 0.2698379 [1] 0.6036739 [1] 0.6762776 > I think I know where the problem is. in the C file, randtoolbox.c, I use the machine time as follows void randSetSeed() { /* struct timeval { unsigned long tv_sec; // seconds since Jan. 1, 1970 long tv_usec; // and microseconds }; */ struct timeval tv; //take the machine time gettimeofday (&tv, NULL); // [ 2^16 * microsecond ] xor [ second ] seed = ((unsigned long long) tv.tv_usec << 16) ^ tv.tv_sec; isInit = 1; } and the C function randSetSeed is called. (in the header file, I include ). I think on windows there is no micro second precision and so the "randomize" seed is the same between two consecutive calls. The same will eventually be true on other machines, when they are fast enough to evaluate two calls during the same microsecond. (I'd guess they're already fast enough if you put that loop in C code instead of R code.) But why would this ever happen? Surely your code doesn't make this call for every random number call; like R, it should make it at most once per session. There is a higher resolution counter in Windows (see QueryPerformanceCounter) if you really need it, and you may have access to the hardware cycle counter if you need even better resolution. But I don't see why you would need these. Duncan Murdoch I try many things to deal with this problem (for example include and use windows specific time function), but it does not work. I'm asking for help on R mailing list because what solve on R for the runif function. You could answer me to go to the R source. Of course, I look there my code is based on this code. But in the RNG.c file which implements random number generation. they use line 271-289 #include #ifdef HAVE_SYS_TIME_H # include #endif static void Randomize(RNGtype kind) { /* Only called by GetRNGstate() when there is no .Random.seed */ Int32 seed; #if HAVE_GETTIMEOFDAY { struct timeval tv; gettimeofday (&tv, NULL); seed = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; } #elif HAVE_TIME seed = (Int32) time(NULL); #else /* unlikely, but use random contents */ #endif srand(seed); RNG_Init(kind, seed); } If I try to use directly the time function on windows rather than gettimeofday (which should not be on windows) but it does not solve the problem. I'm wondering how R has solved this issue? That's where I'm asking for any help. Thanks in advance Christophe PS : I use in both examples R 2.7.1 first on windows XP, second on mac os leopard. __ 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] system time - windows specific problem
Hi all, I'm currently implementing quasi random generation (torus) on R (package randtoolbox available on CRAN). Even if it is not a great idea, I decided to use the machine time to initiate the seed. So when the seed is not specified by the user, the pkg uses the time machine time. Hence the following R code should produce different uniform variates : > for(i in 1:10)print(torus(1)) But on windows, I get : > library(randtoolbox) > for(i in 1:10)print(torus(1)) [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 [1] 0.1313116 > while on mac os, we get : > library(randtoolbox) > for(i in 1:10)print(torus(1)) [1] 0.9730577 [1] 0.9124289 [1] 0.5123534 [1] 0.4640765 [1] 0.9367557 [1] 0.2945414 [1] 0.3671455 [1] 0.2698379 [1] 0.6036739 [1] 0.6762776 > I think I know where the problem is. in the C file, randtoolbox.c, I use the machine time as follows void randSetSeed() { /* struct timeval { unsigned long tv_sec; // seconds since Jan. 1, 1970 long tv_usec; // and microseconds }; */ struct timeval tv; //take the machine time gettimeofday (&tv, NULL); // [ 2^16 * microsecond ] xor [ second ] seed = ((unsigned long long) tv.tv_usec << 16) ^ tv.tv_sec; isInit = 1; } and the C function randSetSeed is called. (in the header file, I include ). I think on windows there is no micro second precision and so the "randomize" seed is the same between two consecutive calls. I try many things to deal with this problem (for example include and use windows specific time function), but it does not work. I'm asking for help on R mailing list because what solve on R for the runif function. You could answer me to go to the R source. Of course, I look there my code is based on this code. But in the RNG.c file which implements random number generation. they use line 271-289 #include #ifdef HAVE_SYS_TIME_H # include #endif static void Randomize(RNGtype kind) { /* Only called by GetRNGstate() when there is no .Random.seed */ Int32 seed; #if HAVE_GETTIMEOFDAY { struct timeval tv; gettimeofday (&tv, NULL); seed = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; } #elif HAVE_TIME seed = (Int32) time(NULL); #else /* unlikely, but use random contents */ #endif srand(seed); RNG_Init(kind, seed); } If I try to use directly the time function on windows rather than gettimeofday (which should not be on windows) but it does not solve the problem. I'm wondering how R has solved this issue? That's where I'm asking for any help. Thanks in advance Christophe PS : I use in both examples R 2.7.1 first on windows XP, second on mac os leopard. __ 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.