Re: [R] RE: How about a mascot for R?
Marc Schwartz wrote: On Fri, 2004-12-17 at 12:32 +1000, Andrew Ward wrote: Apologies for adding to this discussion so late. When the idea of a mascot was first raised, I recalled how in describing (and spelling) R to people in seminars, etc I would sometimes say, in my best pirate voice, "That's R, as in ARR!". The connection to something or someone criminal is perhaps not desirable, but I'm sure that there is someone in the R community who could be a model for the logo (long beard certainly, eye-patch or wooden leg even better). And then clicking on the logo would play the accompanying sound. I think this has plenty of appeal. ;-) Perhaps we could get Johnny Depp (aka Jack Sparrow)? http://www.imdb.com/gallery/ss/0325980/Ss/0325980/PiratesCN-36-6.jpg Or perhaps Jason Isaacs (aka Captain Hook)? http://www.imdb.com/gallery/ss/0316396/Ss/0316396/5576_D137_00042.JPG ;-) Marc Or Keith Richards (aka Keith Richards)? http://images.google.com/images?sourceid=mozclient&ie=utf-8&oe=utf-8&q=keith+richards --sundar __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] RE: How about a mascot for R?
On Fri, 2004-12-17 at 12:32 +1000, Andrew Ward wrote: > Apologies for adding to this discussion so late. > > When the idea of a mascot was first raised, I > recalled how in describing (and spelling) R to > people in seminars, etc I would sometimes say, > in my best pirate voice, "That's R, as in ARR!". > > The connection to something or someone criminal > is perhaps not desirable, but I'm sure that there > is someone in the R community who could be a model > for the logo (long beard certainly, eye-patch or > wooden leg even better). And then clicking on the > logo would play the accompanying sound. I think > this has plenty of appeal. > > ;-) Perhaps we could get Johnny Depp (aka Jack Sparrow)? http://www.imdb.com/gallery/ss/0325980/Ss/0325980/PiratesCN-36-6.jpg Or perhaps Jason Isaacs (aka Captain Hook)? http://www.imdb.com/gallery/ss/0316396/Ss/0316396/5576_D137_00042.JPG ;-) Marc __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] RE: How about a mascot for R?
Apologies for adding to this discussion so late. When the idea of a mascot was first raised, I recalled how in describing (and spelling) R to people in seminars, etc I would sometimes say, in my best pirate voice, "That's R, as in ARR!". The connection to something or someone criminal is perhaps not desirable, but I'm sure that there is someone in the R community who could be a model for the logo (long beard certainly, eye-patch or wooden leg even better). And then clicking on the logo would play the accompanying sound. I think this has plenty of appeal. ;-) Regards, Andrew C. Ward, Senior Analyst (Quantitative), Tel: +61 7 3864 0439 Queensland Studies Authority, Fax: +61 7 3229 3318 295 Ann Street, Brisbane Qld 4000, Australia ~~ This email (including any attached files) is for the intended recipient(s) only. If you received this email by mistake, please, as a courtesy, tell the sender, then delete this email. The views and opinions are the originator's and do not necessarily reflect those of the Queensland Studies Authority. All reasonable precautions have been taken to ensure that this email contained no viruses at the time it was sent. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] counting numbers without replicates in a vector
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Peter Dalgaard > Sent: Thursday, December 16, 2004 5:43 PM > To: Ray Brownrigg > Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: Re: [R] counting numbers without replicates in a vector > > > Ray Brownrigg <[EMAIL PROTECTED]> writes: > > > > I am just wondering if there is an easy way to count > > > in a numeric vector how many numbers don't have > > > replicates. > > > For example, > > > a=c(1,1,2,2,3,4,5), how can I know there are three > > > numbers (3, 4 and 5) without replicates? > > > > > How about: > > length(table(a)[table(a) == 1]) > > Also, probably inefficient, but rather neat: > > > setdiff(a,a[duplicated(a)]) > [1] 3 4 5 Probably not (inefficient): > x <- sample(1:5e4, 2e5, replace=TRUE) > system.time(ans1 <- which(table(x) == 1), gcFirst=TRUE) [1] 1.08 0.00 1.10 NA NA > system.time(ans2 <- setdiff(x, x[duplicated(x)]), gcFirst=TRUE) [1] 0.23 0.02 0.26 NA NA > setdiff(ans2, as.numeric(names(ans1))) numeric(0) Best, Andy > -- >O__ Peter Dalgaard Blegdamsvej 3 > c/ /'_ --- Dept. of Biostatistics 2200 Cph. N > (*) \(*) -- University of Copenhagen Denmark Ph: > (+45) 35327918 > ~~ - ([EMAIL PROTECTED]) FAX: > (+45) 35327907 > > __ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: R: [R] partial linear model
From: "Vito Muggeo" <[EMAIL PROTECTED]> Subject: R: [R] partial linear model Date: Thu, 16 Dec 2004 17:25:35 +0100 > Dear Jin, > if you mean `conditional linearity', (i.e. given the nonlinear parameter, > the model is linear) you can use nls() with algorithm = "plinear". See ?nls > Alternatively, if your model has just one nonlinear parameter th, say, I > think you can write the objective function (for instance the logLik) > depending on th and use optimize() to search for the optimum; Then fit your > model assuming th known (and ignoring its (co)variability.. ). Something > like: > > fn<-function(th,y,X){ > #the deviance function depending on th > #th: nonlinear parameter to be estimated > #y: the response > #X: the design matrix > o<-glm(y~X+_someKnownFunction(th)_+..) > o$dev > } > > #search the optimum > ob<-optimize(fn,.. > > th1<-ob$minimum #(or ob$maximum) > o<-glm(y~X+_someKnownFunction(th1)_+..) #fit the model assuming th=th1 > *known* > > Hope this helps, > vito muggeo > > > - Original Message - > From: Jin Shusong <[EMAIL PROTECTED]> > To: R Help <[EMAIL PROTECTED]> > Sent: Thursday, December 16, 2004 4:33 PM > Subject: [R] partial linear model > > > > Dear all, > > > > Are there any packages can estimate the partial linear > > model. Or any one can give me any suggestions. > > > > Many thanks in advance. > > > > > > Jin > > > > __ > > [EMAIL PROTECTED] mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html Dear Muggeo, You suggestion is so useful and by following you idea, I have written my own program. Thank you very much. Jin __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] (no subject)
__ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Problem with SVM and scaling
Hi all - I am running into a problem with the SVM() method when applying it to data sets that have descriptors with zero variance. Here is the sequence of events: 1. I split my data set with 512 descriptors in a training and test set 2. I build an SVM model for the training set. Out of 512 descriptors, 500 have zero variance which I discard before calling the SVM method 3. For the test set, 8 descriptors have zero variance, which I discard too 4. predict.svm() then fails, because it tries to scale using two vectors of different size (500 and 504) Is there a way to get around this? Thanks - Ton __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] counting numbers without replicates in a vector
Ray Brownrigg <[EMAIL PROTECTED]> writes: > > I am just wondering if there is an easy way to count > > in a numeric vector how many numbers don't have > > replicates. > > For example, > > a=c(1,1,2,2,3,4,5), how can I know there are three > > numbers (3, 4 and 5) without replicates? > > > How about: > length(table(a)[table(a) == 1]) Also, probably inefficient, but rather neat: > setdiff(a,a[duplicated(a)]) [1] 3 4 5 -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] counting numbers without replicates in a vector
On Thu, 2004-12-16 at 13:40 -0800, Jun Ding wrote: > Hi, > I am just wondering if there is an easy way to count > in a numeric vector how many numbers don't have > replicates. > For example, > a=c(1,1,2,2,3,4,5), how can I know there are three > numbers (3, 4 and 5) without replicates? > > Thank you! > > Jun How about: > as.vector(which(table(a) == 1)) [1] 3 4 5 HTH, Marc Schwartz __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] counting numbers without replicates in a vector
> I am just wondering if there is an easy way to count > in a numeric vector how many numbers don't have > replicates. > For example, > a=c(1,1,2,2,3,4,5), how can I know there are three > numbers (3, 4 and 5) without replicates? > How about: length(table(a)[table(a) == 1]) ? Ray Brownrigg __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] counting numbers without replicates in a vector
table will probably do. The following is probably is what you want: > a <- c(1,1,2,2,3,4,5) > a.tab <- table (a) > a.tab a 1 2 3 4 5 2 2 1 1 1 > as.vector(which (a.tab == 1)) [1] 3 4 5 Cheers, Yu Jun Ding wrote: Hi, I am just wondering if there is an easy way to count in a numeric vector how many numbers don't have replicates. For example, a=c(1,1,2,2,3,4,5), how can I know there are three numbers (3, 4 and 5) without replicates? Thank you! Jun = __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] counting numbers without replicates in a vector
?duplicated and ?unique might be of interest to you ... But I think an easier way is: z<-table(a) length(z)-sum(z>1) This gives you the count. names(z)[z==1] gives you the actual values (The quotes can be removed by explicitly calling print with argument quote=FALSE) -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Jun Ding > Sent: Thursday, December 16, 2004 1:41 PM > To: [EMAIL PROTECTED] > Subject: [R] counting numbers without replicates in a vector > > Hi, > I am just wondering if there is an easy way to count > in a numeric vector how many numbers don't have > replicates. > For example, > a=c(1,1,2,2,3,4,5), how can I know there are three > numbers (3, 4 and 5) without replicates? > > Thank you! > > Jun > > > = > > __ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] counting numbers without replicates in a vector
On 12/16/04 13:40, Jun Ding wrote: Hi, I am just wondering if there is an easy way to count in a numeric vector how many numbers don't have replicates. For example, a=c(1,1,2,2,3,4,5), how can I know there are three numbers (3, 4 and 5) without replicates? Take a look at unique() -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron R search page: http://finzi.psych.upenn.edu/ __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] counting numbers without replicates in a vector
Have you considered something like the following: > a [1] 1 1 2 2 3 4 5 > sum(table(a)==1) [1] 3 hope this helps. spencer graves Jun Ding wrote: Hi, I am just wondering if there is an easy way to count in a numeric vector how many numbers don't have replicates. For example, a=c(1,1,2,2,3,4,5), how can I know there are three numbers (3, 4 and 5) without replicates? Thank you! Jun = __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Spencer Graves, PhD, Senior Development Engineer O: (408)938-4420; mobile: (408)655-4567 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] counting numbers without replicates in a vector
Jun Ding wrote: Hi, I am just wondering if there is an easy way to count in a numeric vector how many numbers don't have replicates. For example, a=c(1,1,2,2,3,4,5), how can I know there are three numbers (3, 4 and 5) without replicates? How about using ?table: tab <- table(a) unq <- names(tab)[tab == 1] Then use as.numeric(unq) to convert the names to numbers if needed. --sundar __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] counting numbers without replicates in a vector
Hi, I am just wondering if there is an easy way to count in a numeric vector how many numbers don't have replicates. For example, a=c(1,1,2,2,3,4,5), how can I know there are three numbers (3, 4 and 5) without replicates? Thank you! Jun = __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Advice on parsing formulae
On Thu, 16 Dec 2004, Claus Dethlefsen wrote: Thank you for the advice. I have now boiled my problem down to the following: How do I create fm2 from fm1 ? fm1 <- Y ~ 1 + tvar(x:A) + tvar(z) + u + tvar(B) + tvar(poly(v,3)) fm2 <- Y ~ 1 + x:A + z + u + B + poly(v, 3) Thus, how do I simply remove tvar( * ) from a formula? Do I have to write a function to parse the string and then re-create the formula? Is there an easy way of doing this? One way is to process the formula recursively: no.tvar<-function(formula){ process<-function(expr){ if (length(expr)==1) return(expr) if(length(expr)==2) if ( expr[[1]]==as.name("tvar")) return(expr[[2]]) else return(expr) expr[[2]]<-process(expr[[2]]) expr[[3]]<-process(expr[[3]]) return(expr) } formula[[3]]<-process(formula[[3]]) formula } no.tvar(fm1) Y ~ 1 + x:A + z + u + B + poly(v, 3) This is not the more common sort of problem where you actually want to remove terms from a formula (eg Error() in aov, cluster() and strata() in coxph). You want to modify them in place. -thomas __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
FW: [R] Unsightly lines from x*y grid in levelplot with Postscript
> One typical problem with gv is that some artifacts show up (which may > not be what you describe) when the display is anti-aliased. Try > turning that off (by pressing 'a') and see if that improves the > display. > If you produce PDF, it's possible to just turn off antialiasing for > "line art", so the text doesn't go chunky. Sorry, I should have said this is a Ghostview thing. A summary of the suggestions from Deepayan and Paul: Pressing "a" does fix the problem in Ghostview by turning off the anti-aliasing. It can also be done from the menu under "State." In Adobe Acrobat Reader 5.0, on the Edit menu, in the Preferences dialog, in the Display panel, there are three smoothing checkboxes (one for text, one for line art, and one for images). None of this matters for printing, where the white lines will not show up. --Scott Waichler __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] reading svm function in e1071
The predict method for class `svm' is hidden in a namespace. Try getS3method("predict", "svm") -roger Rajdeep Das wrote: Hi, If I try to read the codes of functions in e1071 package, it gives me following error message. library(e1071) svm function (x, ...) UseMethod("svm") predict.svm Error: Object "predict.svm" not found Can someone help me on this how to read the codes of the functions in the e1071 package? Thanks. Raj [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger D. Peng http://www.biostat.jhsph.edu/~rpeng/ __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] partial linear model
Dear all, Are there any packages can estimate the partial linear model. Or any one can give me any suggestions. Many thanks in advance. Jin __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] reading svm function in e1071
It's in the R FAQ. Try getAnywhere("predict.svm"). Andy > From: Rajdeep Das > > Hi, > > If I try to read the codes of functions in e1071 package, it > gives me following error message. > > >library(e1071) > > > svm > function (x, ...) > UseMethod("svm") > > > > predict.svm > Error: Object "predict.svm" not found > > > > Can someone help me on this how to read the codes of the > functions in the e1071 package? > > Thanks. > > > Raj > [[alternative HTML version deleted]] > > __ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
R: [R] partial linear model
Dear Jin, if you mean `conditional linearity', (i.e. given the nonlinear parameter, the model is linear) you can use nls() with algorithm = "plinear". See ?nls Alternatively, if your model has just one nonlinear parameter th, say, I think you can write the objective function (for instance the logLik) depending on th and use optimize() to search for the optimum; Then fit your model assuming th known (and ignoring its (co)variability.. ). Something like: fn<-function(th,y,X){ #the deviance function depending on th #th: nonlinear parameter to be estimated #y: the response #X: the design matrix o<-glm(y~X+_someKnownFunction(th)_+..) o$dev } #search the optimum ob<-optimize(fn,.. th1<-ob$minimum #(or ob$maximum) o<-glm(y~X+_someKnownFunction(th1)_+..) #fit the model assuming th=th1 *known* Hope this helps, vito muggeo - Original Message - From: Jin Shusong <[EMAIL PROTECTED]> To: R Help <[EMAIL PROTECTED]> Sent: Thursday, December 16, 2004 4:33 PM Subject: [R] partial linear model > Dear all, > > Are there any packages can estimate the partial linear > model. Or any one can give me any suggestions. > > Many thanks in advance. > > > Jin > > __ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] reading svm function in e1071
Hi, If I try to read the codes of functions in e1071 package, it gives me following error message. >library(e1071) > svm function (x, ...) UseMethod("svm") > predict.svm Error: Object "predict.svm" not found > Can someone help me on this how to read the codes of the functions in the e1071 package? Thanks. Raj [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Unsightly lines from x*y grid in levelplot with Postscript
Hi Waichler, Scott R wrote: When I generate levelplot figures with Postscript, the lines from the underlying grid (i.e., the x and y in z ~ x* y) show up as faint white lines in the output. If I have a dense grid, the lines wash out the contour colors. I can avoid the problem if I use png instead, but that brings up other problems. Any ideas for how I can get Postscript to not show those lines around the cells? I think it's ghostview (or whatever viewer you're using) that's showing the lines (not postscript). You don't get the lines when you print do you? Try turning off antialiasing. If you produce PDF, it's possible to just turn off antialiasing for "line art", so the text doesn't go chunky. Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Unsightly lines from x*y grid in levelplot with Postscript
On Thursday 16 December 2004 12:57, Waichler, Scott R wrote: > When I generate levelplot figures with Postscript, the lines from > the underlying grid (i.e., the x and y in z ~ x* y) > show up as faint white lines in the output. If I have a dense grid, > the lines wash out the contour colors. I can avoid the problem if > I use png instead, but that brings up other problems. Any > ideas for how I can get Postscript to not show those lines around > the cells? I'm not sure what you mean. Could you send me an example (off-list)? One typical problem with gv is that some artifacts show up (which may not be what you describe) when the display is anti-aliased. Try turning that off (by pressing 'a') and see if that improves the display. Deepayan __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] drawing a rectangle through multiple plots
Attached is a file with the definition of a function (cnvrt.coords) that can just be sourced into R. This function will convert between the different coordinate systems. The basic usage for your problem is: 1. draw first plot 2. convert the y-value for the top of your rectangle from the current user coordinates to device coordinates 3. draw the second and third plots 4. turn off clipping so that the rectangle can be drawn accross plots 5. convert the number from step 2 into the current user coordinates 6. draw the rectangle using the points in the current usr coordinates (using the doubly converted number for the top). Here is an example similar to yours: par(mfrow=c(3,1)) # first plot plot(1:10, rnorm(10),ylim=c(-4,4),xlab='') ### get the y coordinate of 4 in device units tmp.y <- cnvrt.coords(x=NA,y=4)$dev$y # middle plot plot(1:10, rnorm(10), ylim=c(-4,4),xlab='') #bottom plot plot(1:10, rnorm(10), ylim=c(-4,4)) ### turn off clipping (alow drawn lines to cross all plots) par(xpd=NA) ### convert top to current usr coordinates tmp.y2 <- cnvrt.coords(x=NA, y=tmp.y, input='dev')$usr$y # draw rectangle rect(2.5, -4, 4.5, tmp.y2) Hope this helps, Greg Snow, Ph.D. Statistical Data Center [EMAIL PROTECTED] (801) 408-8111 >>> Dr Carbon <[EMAIL PROTECTED]> 12/14/04 12:41PM >>> How do I draw a rectangle across multiple plots on a device? E.g., def.par <- par(no.readonly = TRUE) par(mfrow = c(3, 1)) plot(1:10, rnorm(10), ylim = c(-4,4), type = "l") plot(1:10, rnorm(10), ylim = c(-4,4), type = "l") plot(1:10, rnorm(10), ylim = c(-4,4), type = "l") rect(2, -4, 3, 4) par(def.par) I want the rectangle to extend across the whole device. How do I get at those coordinates? Is this a case where I should be using grid or gridBase? Thanks. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Unsightly lines from x*y grid in levelplot with Postscript
When I generate levelplot figures with Postscript, the lines from the underlying grid (i.e., the x and y in z ~ x* y) show up as faint white lines in the output. If I have a dense grid, the lines wash out the contour colors. I can avoid the problem if I use png instead, but that brings up other problems. Any ideas for how I can get Postscript to not show those lines around the cells? Scott Scott Waichler, Senior Research Scientist Pacific Northwest National Laboratory MSIN K9-36 P.O. Box 999 Richland, WA 99352USA 509-372-4423 (voice) 509-372-6089 (fax) [EMAIL PROTECTED] http://hydrology.pnl.gov __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Detecting incomplete commands
On 16 Dec 2004, Peter Dalgaard wrote: > "Philippe Grosjean" <[EMAIL PROTECTED]> writes: > > > Thank you Thomas for your answer. This is of course what I intend to do > > (indeed, to use a tryCatch(), instead of I try(). However, I would like to > > have a different behaviour depending if the synthax is incorrect "ls())" for > > instance, or incomplete "ls(" for instance. Indeed, exactly like the > > distinction made at the command line: > > > > > ls()) # This generates an error > > Error: syntax error > > > ls( # This is not an error, but a multiline command > > + > > > > If you use parse() within a try(), you got the same error message in both > > cases: "Error in parse(file, n, text, prompt) : parse error". So, it is not > > possible to discriminate between the two situation in this context. Is it a > > way to cope with that? > > Here's one idea: > > > grep("line 2",try(parse(textConnection("ls)")),silent=T)) > numeric(0) > > grep("line 2",try(parse(textConnection("ls(")),silent=T)) > [1] 1 This is a lot easier at C level: see and `Writing R Extensions'. -- 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 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] na.omit argument in gls()
Hello everyone, I was wondering if someone could tell me what happens when you use na.omit in the gls() function in library(nlme) when you assume a correlation structure for the errors: gls(Y ~ X1 + X2 + X3, data=sample.data, na.action=na.omit, correlation=corARMA(p=1)) Is na.omit is an appropriate argument to use in this case? There is considerable information I could find about imputing missing data - which I have done to determine that the autocorrelation is approximately AR(1) - but I have not found any literature on whether it is then acceptable to omit the imputed data and just use observed measurements for generalized least squares after the correlation structure has been determined. Any help would be very much appreciated. Thank you very much! Satoshi ___ Satoshi Takahama Dept. of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] nls question
Mike nlsList from nlme library can fit nonlinear models for dataset grouped by some specification, e.g. by specie in your case Regards Christian >-- Mensaje Original -- >From: "Mike Saunders" <[EMAIL PROTECTED]> >To: "R Help" <[EMAIL PROTECTED]> >Date: Thu, 16 Dec 2004 10:40:00 -0500 >Subject: [R] nls question > > >Just a quick question. Is there a way to easily specify factor levels in >a function definition within nls? For example, I am trying to fit a 3 parameter, >nonlinear Weibull function to tree height and I would like to have results >by species (or down the road a bit, by plot). I am hoping there is someway >to do it easily, similar to the "gas example" in the ANCOVA chapter in Modern >Applied Statistics with S, and not running it with a "by" function or making >a very complex function statement with all factor levels combinations. > >Can someone point me in the right direction? > >Thanks, >Mike > >Mike Saunders >Research Assistant >Forest Ecosystem Research Program >Department of Forest Ecosystem Sciences >University of Maine >Orono, ME 04469 >207-581-2763 (O) >207-581-4257 (F) > > [[alternative HTML version deleted]] > >__ >[EMAIL PROTECTED] mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] PHP MySQL and R
Hello everyone, this is my first post. Nice to meet all of you. I am having some troubles using R in combination with PHP and MySQL. I would appreciate any assistance very much! This is kind of long, so if you'd like a shorter version let me know. I am working on a project that takes a list of points (inputted via the web, and stored into a MySQL DB), and runs an R script on them. The user receives and e-mail when the script is complete, and can view the output (which, ideally, will be stored in a database and formatted for the web by PHP) What is the best way to do this? As of now, I have it so the user can upload the list of points and they are stored in a database. (see below) When the user requests a job to be run, that is, for the server to use R to process the data, an entry is added to the jobs table. Every x seconds, a daemon (written in PHP) looks at the "jobs" table and looks to see if any are in the "processing" state. If none are, this means the server is free to run a script... so the daemon chooses a job to be run. (and sets its status to processing) At this point this information is available: The R script that needs to be run. The Dataset ID --- Problem #1: How should I call R so that it runs the script, lets call it "bla.R" on the points stored in a MySQL database? Do I have PHP create a temporary file, call the R script with that filename as an argument, and have R just do table.read("temp.txt")? --- --- Problem #2: The R script just runs linear regressions on the data. I'd like to take only SOME of the data outputted by the "summary" function. Let's say we have a simple linear regression on the X and Y points: fit <- lm(X~Y) How can I get R to output something that can be easily split apart and stored into a DB? I want the following values: -Residuals Min -Residuals 1Q -Residuals Median -Residuals 3Q -Residuals Max -The Residual Standard Error -Multiple R-Squared -Adjusted R-Squared -F-Statistic -etc..etc.. How can this be acheived? - Database Structure A list of points is called a Dataset. We have a table called "Datasets" which simply holds all the Datasets: DATASETS id title and a table "Data" which holds all the points of all the datasets: DATA id ds_id x y lagged The points of a Dataset can be found from this query: "SELECT x,y,lagged FROM DATA WHERE ds_id=(whatever dataset)" and the table "jobs" JOBS id script (which r script to run) dataset (which dataset to use) status (queued, processing, or completed) === Thank you all so much for helping me out.. I appreciate it very much and am looking forward to figuring this out! -Sam __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] SAS or R software
> - Output delivery system (ODS): *Every* piece of SAS output is an > output object that can be captured as > a dataset, rendered in RTF, LaTeX, HTML, PDF, etc. with a relatively > simple mechanism (including graphs) > ods pdf file='mystuff.pdf''; > << any sas stuff>> > ods pdf close; R now has this ability as well via the "sinkplot" and "textplot" commands provided by the "gplots" package. -G LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}} __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Percentages in contingency tables *warning trivial question*
On Thu, 2004-12-16 at 17:45 +0100, Dirk Enzmann wrote: > Being still unsatisfied with the CrossTable() function I modified the > code so that the function will create an output similar to the SPSS > procedure CROSSTABS. Most probably the code will not meet most R > programmers' standards, perhaps someone else is willing to optimize it. > Unfortunately, as an R beginner I am not able to write a documentation > file (perhaps someone is willing to put some effort in it, too)- the > parameters that can be used can be found next to "function". > > Including the function code here would cause nasty line breaks, you can > find it at > > http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Software/crosstabs.r > > Dirk Dirk, As the author of the CrossTable() function, I appreciate your additions to the functionality of the code. I will save your e-mail and code and look to incorporate it into the main CrossTable() function as soon as time permits. I will include an appropriate attribution to you for your contribution in the source code and help files. It is my long term goal to enhance the scope of the function with additional outputs (as I have mentioned here and elsewhere previously), but other work related issues have precluded me from getting back to them sooner. The risk of the inclusion of these additional features is that the function becomes something of a behemoth, given all the options for outputs. That approach is contrary to general R philosophy. However, this type of broad formatted cross-tabulation functionality seems to be an issue that comes up frequently. The lack of this was my initial reason for creating the function based upon my own requirements. Having been a former SAS user, I tended to fashion the function on the output of SAS PROC FREQ. I will pass on the updated files to Greg for inclusion in his bundle as soon as I have completed the additions and testing. Best regards and thanks again. Marc Schwartz __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Percentages in contingency tables *warning trivial question*
Being still unsatisfied with the CrossTable() function I modified the code so that the function will create an output similar to the SPSS procedure CROSSTABS. Most probably the code will not meet most R programmers' standards, perhaps someone else is willing to optimize it. Unfortunately, as an R beginner I am not able to write a documentation file (perhaps someone is willing to put some effort in it, too)- the parameters that can be used can be found next to "function". Including the function code here would cause nasty line breaks, you can find it at http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Software/crosstabs.r Dirk At Mon, 13 Dec 2004 05:47:17 -0500 Chuck Cleland <[EMAIL PROTECTED]> wrote: (snip) > You might want to look at CrossTable() in the gmodels package > of the gregmisc bundle. (snip) -- * Dr. Dirk Enzmann Institute of Criminal Sciences Dept. of Criminology Schlueterstr. 28 D-20146 Hamburg Germany phone: +49-040-42838.7498 (office) +49-040-42838.4591 (Billon) fax: +49-040-42838.2344 email: [EMAIL PROTECTED] www: http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Enzmann.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem with postscript graphics device driver
If you mean R 2.0.1, your installation is broken. Here's a quick check of where it should be: > ls(asNamespace("grDevices"), all=TRUE) [1] ".PSenv" ".Quartzenv" ".X11env" [4] ".__NAMESPACE__." ".__S3MethodsTable__." ".packageName" On Thu, 16 Dec 2004, Jeffrey Freedman wrote: > I recently installed R version 2.01 for OS X (version 10.3.6). I now > get the following error message when I try to use the postscript > function: > > Error in get(name.opt, envir = envir) : Object ".PSenv" not found > > This did not happen in previous versions of R (i.e. 1.9). I do not get > this error message when using the pdf graphics device driver. -- 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 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Customizing axis labels with alternating in lattice
On Thursday 16 December 2004 09:58, Waichler, Scott R wrote: > I would like to have complete control over which plots and which > axes have labels in a lattice figure. I tried lots of vectors for > the alternating setting in scales, but none worked. Here is what I > would like to do for a 2 col x 3 row figure, where the x designates a > location I would like to have axis labels: > > ___ > x |_|| > |_||x > x |_|| > x x This should be pretty basic: scales = list(x = list(alternating = FALSE), y = list(alternating = TRUE)) Deepayan __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Customizing axis labels with alternating in lattice
I would like to have complete control over which plots and which axes have labels in a lattice figure. I tried lots of vectors for the alternating setting in scales, but none worked. Here is what I would like to do for a 2 col x 3 row figure, where the x designates a location I would like to have axis labels: ___ x |_|| |_||x x |_|| x x Scott Waichler Pacific Northwest National Laboratory [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] partial linear model
What kinds of terms do you have in mind for the non-linear parts? gam() in both mgcv and gam will accommodate linear terms, so they ought to work, no? Andy > From: Jin Shusong > > Dear all, > > Are there any packages can estimate the partial linear > model. Or any one can give me any suggestions. > > Many thanks in advance. > > > Jin > > __ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Problem with postscript graphics device driver
I recently installed R version 2.01 for OS X (version 10.3.6). I now get the following error message when I try to use the postscript function: Error in get(name.opt, envir = envir) : Object ".PSenv" not found This did not happen in previous versions of R (i.e. 1.9). I do not get this error message when using the pdf graphics device driver. Thanks, Jeff Freedman -- Jeffrey M. Freedman TEL: (518) 437-8712 Atmospheric Information ServicesFAX: (518) 437-8759 Suite 296 CESTM 255 Fuller Road Email: [EMAIL PROTECTED] Albany, NY 12203Web: www.atmosinfo.com [[alternative text/enriched version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] nls question
Just a quick question. Is there a way to easily specify factor levels in a function definition within nls? For example, I am trying to fit a 3 parameter, nonlinear Weibull function to tree height and I would like to have results by species (or down the road a bit, by plot). I am hoping there is someway to do it easily, similar to the "gas example" in the ANCOVA chapter in Modern Applied Statistics with S, and not running it with a "by" function or making a very complex function statement with all factor levels combinations. Can someone point me in the right direction? Thanks, Mike Mike Saunders Research Assistant Forest Ecosystem Research Program Department of Forest Ecosystem Sciences University of Maine Orono, ME 04469 207-581-2763 (O) 207-581-4257 (F) [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Detecting incomplete commands
"Philippe Grosjean" <[EMAIL PROTECTED]> writes: > Thank you Thomas for your answer. This is of course what I intend to do > (indeed, to use a tryCatch(), instead of I try(). However, I would like to > have a different behaviour depending if the synthax is incorrect "ls())" for > instance, or incomplete "ls(" for instance. Indeed, exactly like the > distinction made at the command line: > > > ls()) # This generates an error > Error: syntax error > > ls( # This is not an error, but a multiline command > + > > If you use parse() within a try(), you got the same error message in both > cases: "Error in parse(file, n, text, prompt) : parse error". So, it is not > possible to discriminate between the two situation in this context. Is it a > way to cope with that? Here's one idea: > grep("line 2",try(parse(textConnection("ls)")),silent=T)) numeric(0) > grep("line 2",try(parse(textConnection("ls(")),silent=T)) [1] 1 -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Advice on parsing formulae
Claus Dethlefsen math.aau.dk> writes: : : Thank you for the advice. I have now boiled my problem down to the : following: : : How do I create fm2 from fm1 ? : : fm1 <- Y ~ 1 + tvar(x:A) + tvar(z) + u + tvar(B) + tvar(poly(v,3)) : fm2 <- Y ~ 1 + x:A + z + u + B + poly(v, 3) : : Thus, how do I simply remove tvar( * ) from a formula? Do I have to write a : function to parse the string and then re-create the formula? Is there an : easy way of doing this? If its ok to leave in some extra parentheses you could 1. convert it to a character string, fm1.str and then 2. use gsub to replace all occurrences of "tvar" with "" and then convert it back to a formula: fm1.str <- paste( as.character(fm1)[c(2,1,3)], collapse = "" ) fm2 <- as.formula( gsub("tvar", "", fm1.str) ) __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] PL/R calls fail
Stefan Sobernig wrote: I am currently trying to create a development environment including PostgreSQL 8.0.0rc1, R 2.0.1 and PL/R on a system running Fedora Cora 1. So far, I have suceeded in setting up PostgreSQL and R as a shared library - unfortunately I have not been able to link these two spheres by adding the PostgreSQL add-on PL/R due to some mysterious probs. This is an inappropriate list for such a PL/R specific question. Please sign up for the PL/R list here: http://gborg.postgresql.org/mailman/listinfo/plr-general Thanks, Joe __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Detecting incomplete commands
Thank you Thomas for your answer. This is of course what I intend to do (indeed, to use a tryCatch(), instead of I try(). However, I would like to have a different behaviour depending if the synthax is incorrect "ls())" for instance, or incomplete "ls(" for instance. Indeed, exactly like the distinction made at the command line: > ls()) # This generates an error Error: syntax error > ls( # This is not an error, but a multiline command + If you use parse() within a try(), you got the same error message in both cases: "Error in parse(file, n, text, prompt) : parse error". So, it is not possible to discriminate between the two situation in this context. Is it a way to cope with that? Best, Philippe Grosjean > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Thomas Petzoldt > Sent: Thursday, December 16, 2004 3:18 PM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: [R] Detecting incomplete commands > > Philippe Grosjean wrote: > > Hello, > > > > I need a similar behaviour as with the prompt: asking to complete > > incomplete R command with eval(parse(text = )) Is it a > way to make > > the difference between an illegal and an incomplete R command in a > > string? > > For instance: > > > > > >>parse(text="ls()") > > > > expression(ls()) > > > > This is fine! > > > > > >>parse(text="ls(") > > > > Error in parse(file, n, text, prompt) : parse error > > > > This is an incomplete command, and I want to ask to the user for > > further input (multiline command) > > Hello Phillipe, > > why not using something like this: > > > ok<-try(parse(text="ls("), silent=TRUE) > ok [1] "Error > in parse(file, n, text, prompt) : parse error\n" > attr(,"class") > [1] "try-error" > > and then check if "ok" is an expression: > > > is.expression(ok) > FALSE > > > Thomas P. > > __ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Detecting incomplete commands
Philippe Grosjean wrote: Hello, I need a similar behaviour as with the prompt: asking to complete incomplete R command with eval(parse(text = )) Is it a way to make the difference between an illegal and an incomplete R command in a string? For instance: parse(text="ls()") expression(ls()) This is fine! parse(text="ls(") Error in parse(file, n, text, prompt) : parse error This is an incomplete command, and I want to ask to the user for further input (multiline command) Hello Phillipe, why not using something like this: > ok<-try(parse(text="ls("), silent=TRUE) > ok [1] "Error in parse(file, n, text, prompt) : parse error\n" attr(,"class") [1] "try-error" and then check if "ok" is an expression: > is.expression(ok) FALSE Thomas P. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] 3 questions
Dear Vasilis, > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of vasilis pappas > Sent: Thursday, December 16, 2004 3:30 AM > To: [EMAIL PROTECTED] > Subject: [R] 3 questions . . . > > 2) In my function I make use of the Rcmdr package. But every > time I use my function and the Rcmdr package loads, I get > the R-commander window and I have to delete it every time. So > I wonder if there is a way to avoid R-commander window every > time I load the Rcmdr package. > You could remove the .onAttach() function from the package, which calls Commander() to start the Rcmdr GUI. Because Commander() performs a variety of initialisations, however, your function may not work properly in its absence. It's not possible to know whether you'll run into problems without knowing what you're using in the Rcmdr package. I hope that this helps, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lazy-loading db setup in the R build process
Brian D Ripley <[EMAIL PROTECTED]> writes: > On 16 Dec 2004, Peter Dalgaard wrote: > > > Simon Pickering <[EMAIL PROTECTED]> writes: > > > > [...] > Take a look at cross-compiling (Windows under Linux). We have failed to > make lazy loading of base work under cross-compilation, but do this for > all other packages. Just curious: Was that "failed" as in "didn't quite get it right" or as in "hit an unexpected obstacle"? -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Advice on parsing formulae
Claus Dethlefsen wrote: Thank you for the advice. I have now boiled my problem down to the following: How do I create fm2 from fm1 ? fm1 <- Y ~ 1 + tvar(x:A) + tvar(z) + u + tvar(B) + tvar(poly(v,3)) fm2 <- Y ~ 1 + x:A + z + u + B + poly(v, 3) Thus, how do I simply remove tvar( * ) from a formula? Do I have to write a function to parse the string and then re-create the formula? Is there an easy way of doing this? . . . The Design package does manipulations of this sort to "understand" the model design to generate automatic tests of nonlinearity, pooled main effect + interaction tests, etc. Related to your first issue, Design interprets a formula to find the "innermost" variable which is used on axes when plotting predicted values, and for other purposes. In Function.Design you will see code like TL <- attr(terms(object),"term.labels") #Get inner transformations from <- c('asis(*)','pol(*)','lsp(*)','rcs(*)','catg(*)','scored(*)', 'strat(*)','matrx(*)','I(*)') to <- rep('*',9) trans <- paste("h(",sedit(TL[ac!=9], from, to),")",sep="") #change wrapping function to h() h <- function(x,...) deparse(substitute(x)) for(i in (1:pm)) trans[i] <- eval(parse(text=trans[i])) This may indirectly give you an idea, or you might see if the Design package does what you need in general [it doesn't support orthogonal polynomials, which I no longer find useful; it supports regular polynomials and regression splines]. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Incorrect permissions to edit database package
On Thu, 16 Dec 2004, michael watson (IAH-C) wrote: > I am running R 2.0 on Suse Linux 8.2. I get an error message when > loading a library: Do you mean loading a *package* or a dynamic/shared library? And which one? > "Incorrect permissions to edit the package database, > /usr/lib/R/library/liblisting.Rda: save.locLib(locLibList, curLib)" > > However, when I look at that file, the user I am running R as has r and > w permissions on it > > So firstly - any ideas why I get this error message? And secondly, does > it matter that I am getting it? I don't get it if I run R as root > (obviously) but I don't really want to be doing that (obviously) That file is not part of R, but from the BioC reposTools package. Please ask about problems with BioC packages on the appropriate list. -- 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 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] how R outputs?
If R is run in interactive mode; i.e., interactive() == TRUE, whatever function calls that produced R objects gets printed (by calling the appropriate print() method; known as auto-printing), unless the object is returned invisibly (i.e., wrapped in invisible()). As an example, if you put abs(-3) into a file, then run that through R CMD BATCH, you will not see the output printed. Also, auto-printing is off inside loops; e.g., for (I in 1:10) abs(-3) will not show any output, even if you run it in an interactive session. Andy > From: xudongyuan > > Hi.All and R developers: > When I look into the R source code, I have a > question.Since R has its own data structure(i.e. SEXP),how > does it convert the result to the normal output after it has > computed? For example,when I input, > >abs(-3) > I learned that in R's execution, the expression is parsed to > a parse tree,and becomes a SEXP list. After "eval" function, > the result is still a SEXP. But R outputs: > [1] 3 > The output is normal.So my question is how R makes its SEXP > result into the normal result.Where can I find the place R > makes this convertion in R's source code?Can anyone help me? > thanks > > > dongyuan xu > > __ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lazy-loading db setup in the R build process
On 16 Dec 2004, Peter Dalgaard wrote: > Simon Pickering <[EMAIL PROTECTED]> writes: > > > Hi All, > > > > I have read the article on lazy-loading in the September R news letter, and > > think I have at least a vague grasp on what is happening. > > > > Am I right in thinking that, assuming I were using the same packages, I > > could copy the .rdb & .rdx files from one installation of R (2.0.0) to > > another? > > > > I ask this as I'm trying to cross-compile R (for ARM), and need to use R > > itself to perform the lazy-loading db setup (and probably other things) as > > part of the build process. Therefore I build a native version of R (x86) and > > pass the path of the native R binary as R_EXE in the arm cross-build > > Makefiles (in src/library and its sub-directories). > > > > This fails with the following error: > > > > | make[3]: Entering directory > > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library/base' > > | building package 'base' > > | mkdir -p -- ../../../library/base/demo mkdir -p -- > > | ../../../library/base/man Error in eval(expr, envir, enclos) : may > > | already be using lazy loading on base Execution halted > > | make[3]: *** [all] Error 1 > > | make[3]: Leaving directory > > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library/base' > > | make[2]: *** [R] Error 1 > > | make[2]: Leaving directory > > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library' > > | make[1]: *** [R] Error 1 > > | make[1]: Leaving directory > > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src' > > | make: *** [R] Error 1 > > > > My guess is that as the native version has already been built (and enabled > > lazy-loading, etc.), it's not happy that I'm trying to enable it again. > > Might this be the case? > > > > If so I can see a couple of possible options and I wonder if someone could > > comment on what may or may not be possible to remedy the problem: > > > > * Run the native binary without loading its various database files (is this > > is possible) No. > > * Delete the native database files so they can't be used and will be rebuilt > > for the arm version without complaint No. > > * Simply copy the database files from the native build to the appropriate > > locations in the cross-build (after patching the Makefiles to remove the > > references to R_EXE), assuming that they should be portable across > > architectures? > > The last one might work (try it and see). A little experiment, > replacing Opteron base.rdb/rdx files with i386 counterparts indicated > no immediate (!) ill effects. That should certainly work: I would expect them to be identical for most packages. > The (first) thing that seems to bite your cross compile is in > src/library/base/makebasedb.R: > > baseFileBase <- file.path(.Library,"base","R","base") > > if (file.info(baseFileBase)["size"] < 2) # crude heuristic > stop("may already be using lazy loading on base"); > > in which .Library refers to the running R process, and you probably > want the cross-build library instead. I'm not sure that is the only > place that needs changing though. (It *looks* like the tools for > non-base packages take an argument that would allow the build library > to be distinct from the the one used by the running R). Take a look at cross-compiling (Windows under Linux). We have failed to make lazy loading of base work under cross-compilation, but do this for all other packages. I thought about endian differences (which I gather you have here), but I don't think they matter as we use XDR format for the databases. -- 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 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Advice on parsing formulae
Okay, well you could define a tvar function as follows tvar <- function(term) term Then stick to fm1 X <- model.matrix(fm1,keep.order=TRUE) pAssign <- attr(X, "assign") tvar.terms <- terms( fm1, specials = "tvar",keep.order=TRUE ) idx <- attr(tvar.terms,"specials")$tvar if (attr(tvar.terms,"response")) idx <- idx -1 all.labels <- attr(tvar.terms, "term.labels") tvar.labels <- all.labels[idx] tvarAssign <- match(pAssign, match(tvar.labels, all.labels)) tvarAssign[is.na(tvarAssign)] <- 0 I think that the specials attributes is an index of the variables attribute, hence I have replaced if (attr(tvar.terms,"intercept")) idx <- idx -1 with if (attr(tvar.terms,"response")) idx <- idx -1 check e.g. fm1 <- Y ~ tvar(x:A) + tvar(z) + u + tvar(B) + tvar(poly(v,3)) fm1 <- ~ 1 + tvar(x:A) + tvar(z) + u + tvar(B) + tvar(poly(v,3)) Heather From: "Claus Dethlefsen" <[EMAIL PROTECTED]> To: "'Heather Turner'" <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> Date: 12/16/04 8:33am Subject:RE: [R] Advice on parsing formulae Thank you for the advice. I have now boiled my problem down to the following: How do I create fm2 from fm1 ? fm1 <- Y ~ 1 + tvar(x:A) + tvar(z) + u + tvar(B) + tvar(poly(v,3)) fm2 <- Y ~ 1 + x:A + z + u + B + poly(v, 3) Thus, how do I simply remove tvar( * ) from a formula? Do I have to write a function to parse the string and then re-create the formula? Is there an easy way of doing this? When my above problem is solved, I can (with the help from Heather Turner and Chuck Berry) do the following ## define som data x <- z <- u <- v <- rnorm(5) A <- B <- factor( rep( c(1,2), c(3,2) ) ) ## define my formula fm1 and manually create fm2. fm1 <- Y ~ 1 + tvar(x:A) + tvar(z) + u + tvar(B) + tvar(poly(v,3)) fm2 <- Y ~ 1 + x:A + z + u + B + poly(v, 3) ## extract the term.labels from fm2, make the design matrix and extract 'assign' term.labels <- unname(sapply(attr(terms(fm2), "term.labels"), removeSpace)) X <- model.matrix(fm2,keep.order=TRUE) pAssign <- attr(X, "assign") ## Now, extract the tvar-terms from fm1 tvar.terms <- terms( fm1, specials = "tvar",keep.order=TRUE ) idx <- attr(tvar.terms,"specials")$tvar if (attr(tvar.terms,"intercept")) idx <- idx -1 tvar <- attr(terms(fm2,keep.order=TRUE),"term.labels")[idx] tvar <- unname( sapply( tvar, removeSpace) ) ## Finally, combine the information to get the vector I asked for tvarAssign <- match(pAssign, sort(match(tvar, term.labels))) tvarAssign[is.na(tvarAssign)] <- 0 Mrs H Turner Research Assistant Dept. of Statistics University of Warwick __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] (D)COM "unknown (internal) error"
Hello All, I'm getting the error message "unknown (internal) error" when evaluating the following string source('j:/tmp/test.r') via the (D)COM server. The script test.r is run and everything works, but Evaluate still returns this error. I can avoid the error by using EvaluateNoReturn, but would prefer to use Evaluate. I'm running R 2.0.1 and (D)COM 1.35 on WindowsXP. I've tested it in our own DCOM implementation and using the RExcel interface, and get the same error message in both cases. Thanks in advance for any input Jonnie White __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lazy-loading db setup in the R build process
Simon Pickering <[EMAIL PROTECTED]> writes: > Hi All, > > I have read the article on lazy-loading in the September R news letter, and > think I have at least a vague grasp on what is happening. > > Am I right in thinking that, assuming I were using the same packages, I > could copy the .rdb & .rdx files from one installation of R (2.0.0) to > another? > > I ask this as I'm trying to cross-compile R (for ARM), and need to use R > itself to perform the lazy-loading db setup (and probably other things) as > part of the build process. Therefore I build a native version of R (x86) and > pass the path of the native R binary as R_EXE in the arm cross-build > Makefiles (in src/library and its sub-directories). > > This fails with the following error: > > | make[3]: Entering directory > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library/base' > | building package 'base' > | mkdir -p -- ../../../library/base/demo mkdir -p -- > | ../../../library/base/man Error in eval(expr, envir, enclos) : may > | already be using lazy loading on base Execution halted > | make[3]: *** [all] Error 1 > | make[3]: Leaving directory > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library/base' > | make[2]: *** [R] Error 1 > | make[2]: Leaving directory > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library' > | make[1]: *** [R] Error 1 > | make[1]: Leaving directory > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src' > | make: *** [R] Error 1 > > My guess is that as the native version has already been built (and enabled > lazy-loading, etc.), it's not happy that I'm trying to enable it again. > Might this be the case? > > If so I can see a couple of possible options and I wonder if someone could > comment on what may or may not be possible to remedy the problem: > > * Run the native binary without loading its various database files (is this > is possible) > > * Delete the native database files so they can't be used and will be rebuilt > for the arm version without complaint > > * Simply copy the database files from the native build to the appropriate > locations in the cross-build (after patching the Makefiles to remove the > references to R_EXE), assuming that they should be portable across > architectures? The last one might work (try it and see). A little experiment, replacing Opteron base.rdb/rdx files with i386 counterparts indicated no immediate (!) ill effects. The (first) thing that seems to bite your cross compile is in src/library/base/makebasedb.R: baseFileBase <- file.path(.Library,"base","R","base") if (file.info(baseFileBase)["size"] < 2) # crude heuristic stop("may already be using lazy loading on base"); in which .Library refers to the running R process, and you probably want the cross-build library instead. I'm not sure that is the only place that needs changing though. (It *looks* like the tools for non-base packages take an argument that would allow the build library to be distinct from the the one used by the running R). -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Incorrect permissions to edit database package
Hi I am running R 2.0 on Suse Linux 8.2. I get an error message when loading a library: "Incorrect permissions to edit the package database, /usr/lib/R/library/liblisting.Rda: save.locLib(locLibList, curLib)" However, when I look at that file, the user I am running R as has r and w permissions on it So firstly - any ideas why I get this error message? And secondly, does it matter that I am getting it? I don't get it if I run R as root (obviously) but I don't really want to be doing that (obviously) Cheers Mick __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] PL/R calls fail
Hi all, I am currently trying to create a development environment including PostgreSQL 8.0.0rc1, R 2.0.1 and PL/R on a system running Fedora Cora 1. So far, I have suceeded in setting up PostgreSQL and R as a shared library - unfortunately I have not been able to link these two spheres by adding the PostgreSQL add-on PL/R due to some mysterious probs. I thoroughly followed the setup instructions for PL/R (see http://www.joeconway.com/plr/doc/plr-install.html) and arrived at being able to register PL/R with PostgreSQL properly and even to create PL/R-specific functions. >But< whenever trying to invoke these functions, I end up with a single exception, even for simple ones which are just supposed to return the previously passed arguments: ##snip### ERROR: R interpreter parse error ##snip### A closer look at the postmaster's/ postgres's log-file reveals that a hardly more specific exception is thrown at this level, i.e.: ##snip### ERROR: R interpreter parse error DETAIL: R parse error caught in "PLR17706 <- function(arg1,arg2) { if (arg1 > arg2) return(arg1) else return(arg2) }". CONTEXT: In PL/R function r_max ##snip### Even gdb monitoring did not provide any further hint, using older PostgreSQL, R and PL/R versions didn't make a difference. I would kindly ask for your help and thoughts! best regards, Stefan [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Lazy-loading db setup in the R build process
Hi All, I have read the article on lazy-loading in the September R news letter, and think I have at least a vague grasp on what is happening. Am I right in thinking that, assuming I were using the same packages, I could copy the .rdb & .rdx files from one installation of R (2.0.0) to another? I ask this as I'm trying to cross-compile R (for ARM), and need to use R itself to perform the lazy-loading db setup (and probably other things) as part of the build process. Therefore I build a native version of R (x86) and pass the path of the native R binary as R_EXE in the arm cross-build Makefiles (in src/library and its sub-directories). This fails with the following error: | make[3]: Entering directory `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library/base' | building package 'base' | mkdir -p -- ../../../library/base/demo mkdir -p -- | ../../../library/base/man Error in eval(expr, envir, enclos) : may | already be using lazy loading on base Execution halted | make[3]: *** [all] Error 1 | make[3]: Leaving directory `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library/base' | make[2]: *** [R] Error 1 | make[2]: Leaving directory `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library' | make[1]: *** [R] Error 1 | make[1]: Leaving directory `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src' | make: *** [R] Error 1 My guess is that as the native version has already been built (and enabled lazy-loading, etc.), it's not happy that I'm trying to enable it again. Might this be the case? If so I can see a couple of possible options and I wonder if someone could comment on what may or may not be possible to remedy the problem: * Run the native binary without loading its various database files (is this is possible) * Delete the native database files so they can't be used and will be rebuilt for the arm version without complaint * Simply copy the database files from the native build to the appropriate locations in the cross-build (after patching the Makefiles to remove the references to R_EXE), assuming that they should be portable across architectures? Many thanks, Simon Simon Pickering MEng Research Officer Materials Research Centre Faculty of Engineering & Design University of Bath Bath, BA2 7AY, UK Tel: +44 (0)1225 384802 Fax: +44 (0)1225 386928 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R: optimisation
Patrick Burns wrote: You don't say what sort of optimisation you have in mind. If you are looking for something that will handle "non-standard" problems, you can have a look at 'genopt' from S Poetry. Some CRAN packages: gafit seao, seao.gui lpSolve linprog minpack.lm rgenoud (at least) Kjetil Halvorsen Patrick Burns Burns Statistics [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") Clark Allan wrote: hi all other than optim, optimise, and some other related optimisation functions are there any optimisation packages in R? __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Kjetil Halvorsen. Peace is the most effective weapon of mass construction. -- Mahdi Elmandjra __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] 3 questions
Please learn to wrap your emails at about 72 characters. See below for other comments. On Thu, 2004-12-16 at 08:29, vasilis pappas wrote: > Hello R users, > >I have three questions and I would be grateful if someone could give me an > answer to each of these. > > 1) I have constracted a function that returns an output, which runs in a > while( condition ){ run function } loop. I would like to know if there is a > way to get the outputs in different windows, every time the function runs, so > as to compare easier the results. This depends on what you mean by 'output'. If you mean graphs, then you can use x11() if you have X Window systems or windows() if you are in Windows OS. windows() plot(1:10) windows() plot(rnorm(1000)) Or you could use the mfrow option in par() to split the plotting window par(mfrow=c(1,2) plot(1:10) plot(rnorm(1000)) If your output is not graphical, then you can save to a file and compare them or save it to a list/matrix in R. > 2) In my function I make use of the Rcmdr package. But every time I use my > function and the Rcmdr package loads, I get the R-commander window and I have > to delete it every time. So I wonder if there is a way to avoid R-commander > window every time I load the Rcmdr package. > > 3) My final question is if there is a function in R that computes the > Mallow's Cp statistic. I have already found AIC and BIC but not Mallow's Cp. > Furthermore I found leaps() function but it is not exactly what I want. There is a function called mle.cp in the package wle. Not sure if this does what you want. > Thank you for you attention.I will looking forward for some answers. > > > > > - > >@yahoo.gr > > [[alternative HTML version deleted]] > > __ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] 3 questions
> 1) I have constracted a function that returns an output, which runs in a while ( condition ){ run function } > loop. I would like to know if there is a way to get the outputs in different windows, every time the function > runs, so as to compare easier the results. Try windows(). But better don't use it, R has much better tools to compare outputs; trellis' plots (?lattice) main use is to make nicely comparable output. Dieter __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] help with multiple imputation using imp.mix
Hi Jens, On 16-Dec-04 Jens Hainmueller wrote: > I am desperately trying to impute missing data using > 'imp.mix' but always run into this yucky error message > to which I cannot find the solution. > It's the first time I am using mix and I'm trying really > hard to understand, but there's just this one step I don't > get...perhaps someone knows the answer? > > Thanks! > Jens > > My code runs: > > data<-read.table('http://www.courses.fas.harvard.edu/~gov2001/Data/immig > rati > on.dat',header=TRUE) > library(mix) > rngseed(12345678) ># Preare data for imputation > gender1<-c() > gender1<-as.integer(data$gender) > gender1[gender1==1]<-2 > gender1[gender1==0]<-1 > data$gender<-gender1 > x<-cbind(data$gender,data$ipip,data$ideol,data$prtyid, data$wage1992) > colnames(x)<-c("gender","ipip", "ideol", "prtyid","wage") ># start imputation > s <- prelim.mix(x,4) > thetahat <- em.mix(s) > > And here comes the error message: > >> newtheta <- da.mix(s,thetahat, steps=100,showits=TRUE) > Steps of Data Augmentation: > 1...Error in da.mix(s, thetahat, steps = 100, showits = TRUE) : > Improper posterior--empty cells >> imp.mix(s, newtheta, x) This is my first shot, basically somewhat of a guess since I don;t have details of your data. It looks as though you have categorical variables "gender","ipip", "ideol", "prtyid" (at least I hope so -- 'mix' requires you to put all the categoricals first) and one "continuous" variable "wage". Am I correct? (specifically for "ipip" whose nature I can't guess, while I can for the others). The thing to note is that, by default, 'mix' will create category cells using all possible factorial combinations of the levels of your categorical variables. So you could end up with a large number of category cells. E.g. if there are 2 levels for "gender", 4 for "ipip", 5 for "ideol" and 6 for "partyid", then 'mix' will create 2x4x5x6 = 240 distinct category cells of data, and will fit a separate mean (or multivariate mean, depending on how many continuous variables you have) for each category cell, and a common variance (or covariance matrix) for all such cells. It will also estimate the multinomial distribution over the (e.g. 240) category cells. This is the "unrestricted model" corresponding to all possible degrees of interaction between the categoricals, and is what is adopted when (as you did) you use 'em.mix' followed by 'da.mix'. Then, when it comes to imputation, it puts a Dirichlet prior on the multinomial for category cells and a multivariate normal prior on the vector means and a Wishart prior on the covariance matrix for the MV normal distribution of the continuous variables. Then it samples from the joint multinomial x multivariate distribution for the observations which has been randomly chosen according to these priors. Now, if it happens that because of the large number of category cells there are several of these empty in your data, then the above process can fail leading to such error messages. One way round this is to restrict the categorical model, so as to decrease the degrees of interaction between the categoricals. To do this, you use 'ecm.mix' followed by 'dabipf.mix', using the parameters "design" and "margins" to specify your restricted model. NB It can be tricky to get this right! You could experiment to see if the "empty cell" problem described above is what is causing your problems, by trying imputation using fewer categorical variables (e.g. 2 at a time instead of all 4) with the simple 'em.mix' and 'da.mix' before tangling with the more complicated issues arising from 'ecm.mix' and 'dabipf.mix'. The results of this may not be definitive, but could be useful in locating where the problem lies. I hope this helps, Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 [NB: New number!] Date: 16-Dec-04 Time: 09:51:42 -- XFMail -- __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Detecting incomplete commands
Hello, I need a similar behaviour as with the prompt: asking to complete incomplete R command with eval(parse(text = )) Is it a way to make the difference between an illegal and an incomplete R command in a string? For instance: > parse(text="ls()") expression(ls()) This is fine! > parse(text="ls(") Error in parse(file, n, text, prompt) : parse error This is an incomplete command, and I want to ask to the user for further input (multiline command) > parse(text="ls())") Error in parse(file, n, text, prompt) : parse error This is clearly an illegal command. Could I make a distinction with the previous case here? Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Pentagone ( ( ( ( (Academie Universitaire Wallonie-Bruxelles ) ) ) ) ) 6, av du Champ de Mars, 7000 Mons, Belgium ( ( ( ( ( ) ) ) ) ) phone: + 32.65.37.34.97, fax: + 32.65.37.33.12 ( ( ( ( (email: [EMAIL PROTECTED] ) ) ) ) ) ( ( ( ( (web: http://www.umh.ac.be/~econum ) ) ) ) ) .. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Advice on parsing formulae
"Claus Dethlefsen" <[EMAIL PROTECTED]> writes: > Thank you for the advice. I have now boiled my problem down to the > following: > > How do I create fm2 from fm1 ? > > fm1 <- Y ~ 1 + tvar(x:A) + tvar(z) + u + tvar(B) + tvar(poly(v,3)) > fm2 <- Y ~ 1 + x:A + z + u + B + poly(v, 3) > > Thus, how do I simply remove tvar( * ) from a formula? Do I have to write a > function to parse the string and then re-create the formula? Eek, no!! > Is there an > easy way of doing this? Not really. Recursively descend the parse tree and replace calls to tvar with its argument. Probably ends with one of those 10-line functions that take hours to get right... Something like this would go in the middle if (is.call(e)) if (e[[1]]==as.name("tvar")) e[[2]] else for (i in 2:length(e)) e[[i]] <- myfun(e[[i]]) else e If you don't mind getting left with a couple of extra parentheses, this seems to work: > eval(substitute(substitute(fm1,list(tvar=as.name("("))),list(fm1=fm1))) Y ~ 1 + (x:A) + (z) + u + (B) + (poly(v, 3)) (Note to self: we need a substitute() variant that takes a variable, not a literal as the first argument.) -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] AUC for logistic regression [was: (no subject)]
At 20:21 15/12/2004, Kerry Bush wrote: Your formula is only a trapzoidal approximation to the theoretical AUC. It might be downward biased. I am also wondering if there is a funcion in R that can compute the MLE estimate for AUC. Kerry I agree with you. But I dont Know compute the MLE estimate for AUC and its standatr error. Second I dont know MLE(AUC)/SE is normal so I dont konw wich test use. Third I dont konw compute the correction is necessary because the test in same population. If You explain me this topics I upgrade the funciotn with pleasure. But same with a possible downward bias the function solve Roman problem... Thanks in advance Bernardo Rangel Tura, MD, MSc National Institute of Cardiology Laranjeiras Rio de Janeiro Brazil -- No virus found in this outgoing message. Checked by AVG Anti-Virus. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] [R-pkgs] Building of Windows binary packages for R-1.9.x has been stopped
Dear useRs, automatical building of contributed Windows binary packages for R-1.9.x has been stopped. The last known good versions of contributed packages are available in the repository: These may be outdated versions, because new versions of many packages already require R>=2.0.0. Upgrading to R-2.0.1 is recommended. Uwe Ligges ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Advice on parsing formulae
Thank you for the advice. I have now boiled my problem down to the following: How do I create fm2 from fm1 ? fm1 <- Y ~ 1 + tvar(x:A) + tvar(z) + u + tvar(B) + tvar(poly(v,3)) fm2 <- Y ~ 1 + x:A + z + u + B + poly(v, 3) Thus, how do I simply remove tvar( * ) from a formula? Do I have to write a function to parse the string and then re-create the formula? Is there an easy way of doing this? When my above problem is solved, I can (with the help from Heather Turner and Chuck Berry) do the following ## define som data x <- z <- u <- v <- rnorm(5) A <- B <- factor( rep( c(1,2), c(3,2) ) ) ## define my formula fm1 and manually create fm2. fm1 <- Y ~ 1 + tvar(x:A) + tvar(z) + u + tvar(B) + tvar(poly(v,3)) fm2 <- Y ~ 1 + x:A + z + u + B + poly(v, 3) ## extract the term.labels from fm2, make the design matrix and extract 'assign' term.labels <- unname(sapply(attr(terms(fm2), "term.labels"), removeSpace)) X <- model.matrix(fm2,keep.order=TRUE) pAssign <- attr(X, "assign") ## Now, extract the tvar-terms from fm1 tvar.terms <- terms( fm1, specials = "tvar",keep.order=TRUE ) idx <- attr(tvar.terms,"specials")$tvar if (attr(tvar.terms,"intercept")) idx <- idx -1 tvar <- attr(terms(fm2,keep.order=TRUE),"term.labels")[idx] tvar <- unname( sapply( tvar, removeSpace) ) ## Finally, combine the information to get the vector I asked for tvarAssign <- match(pAssign, sort(match(tvar, term.labels))) tvarAssign[is.na(tvarAssign)] <- 0 > -Original Message- > From: Heather Turner [mailto:[EMAIL PROTECTED] > Sent: 15. december 2004 11:41 > To: [EMAIL PROTECTED] > Subject: Re: [R] Advice on parsing formulae > > > I think this will do what you want: > > # Need this function to remove spaces from term labels later on > > removeSpace <- function(string) gsub("[[:space:]]", "", string) > > # Specify which terms are in a "tvar" group > # (could remove spaces separately) > > tvar <- unname(sapply(c("x:A", "z", "B", "poly(v,3)"), removeSpace)) > > # Use terms to get term labels from formula > > formula <- Y ~ 1 + x:A + z + u + B + poly(v,3) > > term.labels <- unname(sapply(attr(terms(formula), > "term.labels"), removeSpace)) > > tvar > [1] "x:A" "z" "B" "poly(v,3)" > > term.labels > [1] "z" "u" "B" "poly(v,3)" "x:A" > > # Get assign variable for parameters > # (You would use first two lines, but I don't have data so > defined assign variable myself) > > #X <- model.matrix(formula) > > #pAssign <- attr(X, "assign") > > pAssign <- c(0,1,2,3,4,4,4,5,5) > > # Define "tvarAssign" > > tvarAssign <- match(pAssign, sort(match(tvar, term.labels))) > > tvarAssign[is.na(tvarAssign)] <- 0 > > tvarAssign > [1] 0 1 0 2 3 3 3 4 4 > > HTH > > Heather > > Mrs H Turner > Research Assistant > Dept. of Statistics > University of Warwick > > >>> "Claus Dethlefsen" <[EMAIL PROTECTED]> 12/13/04 04:10pm >>> > Dear list > > I would like to be able to group terms in a formula using a > function that I > will call tvar(), eg. the formula > > Y ~ 1 + tvar(x:A) + tvar(z) + u + tvar(B) + tvar(poly(v,3)) > > where x,u and v are numeric and A and B are factors - binary, say. > > As output, I want the model.matrix as if tvar had not been > there at all. In > addition, I would like to have information on the grouping, > as a vector as > long as ncol( model.matrix ) with zeros corresponding to > terms outside tvar > and with an index grouping the terms inside each tvar(). In the (sick) > example: > > > > model.matrix(Y ~ 1 + tvar(x:A) + tvar(z) + u + tvar(B) + > tvar(poly(v,3))) >(Intercept) z u B2 poly(v, 3)1 poly(v, 3)2 poly(v, > 3)3 x:A1 > x:A2 > 11 -1.55 -1.03 0 0.160 -0.350 > -0.281 0.66 > 0.00 > 21 -1.08 0.55 0 -0.164 -0.211 > 0.340 0.91 > 0.00 > 31 0.29 -0.26 0 -0.236 -0.073 > 0.311 -1.93 > 0.00 > 41 -1.11 0.96 0 0.222 -0.285 > -0.385 -0.23 > 0.00 > 51 0.43 -0.76 1 -0.434 0.515 > -0.532 0.22 > 0.00 > > I would like the vector > > c(0,1,0,2,3,3,3,4,4) > > pointing to the tvar-grouped terms. > > Thus what I would like, looks a bit like the 'assign' attribute of the > model.matrix() output. I have not figured out a way of doing > this in a nice > way and would like some help, please. > > I hope somebody can help me (or point the manual-pages I should read), > > Best, > > Claus Dethlefsen > -- > Assistant Professor, Claus Dethlefsen, Ph.D. > mailto:[EMAIL PROTECTED], http://www.math.auc.dk/~dethlef > Dpt. of Mathematical Sciences, Aalborg University > Fr. Bajers Vej 7G, 9220 Aalborg East > Denmark > -- No virus found in this outgoing message. Checked by AVG Anti-Virus. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read t
[R] 3 questions
Hello R users, I have three questions and I would be grateful if someone could give me an answer to each of these. 1) I have constracted a function that returns an output, which runs in a while( condition ){ run function } loop. I would like to know if there is a way to get the outputs in different windows, every time the function runs, so as to compare easier the results. 2) In my function I make use of the Rcmdr package. But every time I use my function and the Rcmdr package loads, I get the R-commander window and I have to delete it every time. So I wonder if there is a way to avoid R-commander window every time I load the Rcmdr package. 3) My final question is if there is a function in R that computes the Mallow's Cp statistic. I have already found AIC and BIC but not Mallow's Cp. Furthermore I found leaps() function but it is not exactly what I want. Thank you for you attention.I will looking forward for some answers. - ÁðïêôÞóôå ôçí äùñåÜí [EMAIL PROTECTED] [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html