[R] problem in installing R packages on linux
I am facing problem in installing the R package on linux . When i put the command install.packages(BART) Then it asks for selecting the mirror , i have selected the mirrror , but it is showing no package in repository .I have selected different different repository still i am getting the same error what can i do , please help me out.i am sending the screenshot of unix terminal . I will be thankful to you.Please help me out . http://www.nabble.com/file/p16760370/manish.png manish.png -- View this message in context: http://www.nabble.com/problem-in-installing-R--packages-on-linux-tp16760370p16760370.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problem in installing R packages on linux
I am facing problem in installing the R package on linux . When i put the command install.packages(BART) Then it asks for selecting the mirror , i have selected the mirrror , but it is showing no package in repository .I have selected different different repository still i am getting the same error what can i do , please help me out.i am sending the screenshot of unix terminal . I will be thankful to you.Please help me out . http://www.nabble.com/file/p16760369/manish.png manish.png -- View this message in context: http://www.nabble.com/problem-in-installing-R--packages-on-linux-tp16760369p16760369.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] glm(quasipoisson) with non-integer response
On Thu, 17 Apr 2008, Mark wrote: Hi, I have count data that have been meddled with enough to make them non integers. Using glm(poisson) returns a non integer error but glm(quasipoisson) does not. Just wondering if anyone knows if I am violating the assumptions of a quasipoisson error structure by using these non-integer response data? No, it just assumes variance \propto mean. Thanks! I'd welcome your thoughts and/or references... The help page gives the references -- 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.
Re: [R] problem in installing R packages on linux
man4ish wrote: I am facing problem in installing the R package on linux . When i put the command install.packages(BART) The screenshot is not there, but I suspect you want to install package BARD rather than BART. Uwe Ligges Then it asks for selecting the mirror , i have selected the mirrror , but it is showing no package in repository .I have selected different different repository still i am getting the same error what can i do , please help me out.i am sending the screenshot of unix terminal . I will be thankful to you.Please help me out . http://www.nabble.com/file/p16760370/manish.png manish.png __ 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] multivariate time series
Hello Erin, have you considered the package bundle dse on CRAN? Best, Bernhard Dear R People: I was looking to see if there are any functions for Vector ARMA modeling. I found Vector AR(p) but no Vector ARMAs. Thanks, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ 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. * Confidentiality Note: The information contained in this ...{{dropped:10}} __ 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] spatialpixelsdataframe
Dave Depew wrote: I have a spatialpixelsdataframe containing bathymetry data. Is it possible to save this as something similar to the meuse.grid so it can be loaded without having to run the spatial interpolation each time the script is called? I don't see a straightforward method in the sp documentation. __ 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. Hi Dave, You can save the SpatialPixelsDataFrame to a file using: save(SPDF_object, file =test.rda) And reload it with: load(test.rda) This is not specific to the sp-package. These kinds of questions are better to post to the r-sig-geo mailing list. 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: +31302535773 Fax:+31302531145 http://intamap.geo.uu.nl/~paul __ 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] vector in filename
Hi, Simon Blomberg wrote: How about this: x - 1 y - 1 mmax - 10 my.files - paste(foo, x:mmax, .png, sep=) for (i in my.files) { png(filename=i, pointsize=20, width=600, height=600, units=px, bg=#eaedd5) plot(x, y) dev.off() x - x+1 y - y+1 } It does the trick! Thanks. Normally I would avoid for loops, but I think this application is a legitimate use. Please, why do you avoid looping normally? Thanks again. Greetings, Ricardo -- Ricardo Rodríguez Your XEN ICT Team __ 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] Overall p-value from a factor in a coxph fit
Hi all. If I run the simple regression when x is a categorical variable ( x - factor(x) ): MyFit -coxph( Surv(start, stop, event) ~ x ) How can I get the overall p-value on x other than for each dummy variable? anova(MyFit) does NOT provide that information as previously suggested on the list. All the best, Kare [[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] validation of logistic regression model with weighted presences and absences
Hello everyone! I want to validate logistic regression models of species distrubution data where presences and absences are weighted differently. I used lrm from Design package but unfortunately, validate.lrm ignores weights in the validation process. Has anyone an idea (package, code) how I can do the validation including weights? Thanks a lot! Eva [EMAIL PROTECTED] __ 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] EM algorithm for multiple-locus haplotypes frequencies
From: Marcin Kozak [EMAIL PROTECTED] Subject: [R] EM algorithm for multiple-locus haplotypes frequencies Hi all, I've been looking in R for an EM algorithm adjusted for multiple-locus haplotypes frequencies, but failed in 100%. Has anyone heard of anything of this kind in R? Look at all the libraries whose name starts haplo eg haplo.stats. -- | David Duffy (MBBS PhD) ,-_|\ | email: [EMAIL PROTECTED] ph: INT+61+7+3362-0217 fax: -0101 / * | Epidemiology Unit, Queensland Institute of Medical Research \_,-._/ | 300 Herston Rd, Brisbane, Queensland 4029, Australia GPG 4D0B994A v __ 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] how to find the multiregression on the
I am trying to calculate the multi regression for the follwing data 0 1 2 3 7 5 0 4 4 3 0 3 4 5 4 0 5 4 5 4 0 1 1 0 1 0 1 1 1 0 1 0 4 5 6 1 2 3 2 1 keeping Ist column as dependent variable and other as independent varialbles,how can i do this using lm funciotn in stats please send me the code for this , i will really thankful to you manish gupta http://www.nabble.com/file/p16760374/inp.txt inp.txt -- View this message in context: http://www.nabble.com/how-to-find-the-multiregression-on-the-tp16760374p16760374.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] space between plots
I've set layout(matrix(c(1,3,2,4),ncol=2)) and par(mar=c(0, 4, 4, 0) + 0.0) and par(mar=c(0, 0, 4, 3) + 0.0) for the upper-left and upper-right plots, but still get an space between both plots, is there any way to completely eliminate that space? Thanks Agus -- Dr. Agustin Lobo Institut de Ciencies de la Terra Jaume Almera (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: [EMAIL PROTECTED] http://www.ija.csic.es/gt/obster __ 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] Permanent change to the working directory
Dear helpers, I've looked in the help files (maybe not very thoroughly but I looked) and I couldn't find a straightforward way to permanently set the working directory (where I save and read files). Each time I startup R the working dir is automatically C:/R/bin [using:getwd()], and I know I can change it using setwd [for example setwd(C:/R/DATA), but it's only a transient change for the session, when I close and start a new R session it's in C:/R/bin again. How can I set it definitively to C:/R/DATA without having to redo it every session? Thanks -- View this message in context: http://www.nabble.com/Permanent-change-to-the-working-directory-tp16761149p16761149.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Permanent change to the working directory
On windows machines you could change the `Start in' field of the desktop shortcut for R to the desired working directory - you will find this in the properties of the shortcut. You could easily create several shortcuts for different projects this way. You may also consider changing your .Rprofile, see ?.Rprofile hth. francogrex schrieb: Dear helpers, I've looked in the help files (maybe not very thoroughly but I looked) and I couldn't find a straightforward way to permanently set the working directory (where I save and read files). Each time I startup R the working dir is automatically C:/R/bin [using:getwd()], and I know I can change it using setwd [for example setwd(C:/R/DATA), but it's only a transient change for the session, when I close and start a new R session it's in C:/R/bin again. How can I set it definitively to C:/R/DATA without having to redo it every session? Thanks -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/42803-8243 F ++49/40/42803-7790 __ 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 in installing R packages on linux
Uwe Ligges-3 wrote: man4ish wrote: I am facing problem in installing the R package on linux . When i put the command install.packages(BART) The screenshot is not there, but I suspect you want to install package BARD rather than BART. Uwe Ligges Then it asks for selecting the mirror , i have selected the mirrror , but it is showing no package in repository .I have selected different different repository still i am getting the same error what can i do , please help me out.i am sending the screenshot of unix terminal . I will be thankful to you.Please help me out . http://www.nabble.com/file/p16760370/manish.png manish.png __ 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. No i am trying to install BART which is valid name , i have 30-40 times for other packages still facing the same pblm .How can i rectify this.Please help me out. - Show quoted text - -- View this message in context: http://www.nabble.com/problem-in-installing-R--packages-on-linux-tp16760370p16762342.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Permanent change to the working directory
On 4/18/2008 3:15 AM, francogrex wrote: Dear helpers, I've looked in the help files (maybe not very thoroughly but I looked) and I couldn't find a straightforward way to permanently set the working directory (where I save and read files). Each time I startup R the working dir is automatically C:/R/bin [using:getwd()], and I know I can change it using setwd [for example setwd(C:/R/DATA), but it's only a transient change for the session, when I close and start a new R session it's in C:/R/bin again. How can I set it definitively to C:/R/DATA without having to redo it every session? Thanks ?Startup -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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] Is there any function to skip a loop in a for loop ?
next break Another 'Introduction to R', or even ?for question G. On Fri, Apr 18, 2008 at 04:55:01PM +0800, Ng Stanley wrote: Hi, Is there any function to skip a loop in a for loop ? Thanks Stanley [[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. -- Csardi Gabor [EMAIL PROTECTED]UNIL DGM __ 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] space between plots
When I try this: layout(matrix(c(1,3,2,4),ncol=2)) par(mar=c(0, 4, 4, 0) + 0.0) plot(1) par(mar=c(0, 0, 4, 3) + 0.0) plot(2) plot(3) plot(4) the upper left and right are butted together. Exactly what 'space' are you talking about? On Fri, Apr 18, 2008 at 4:19 AM, Agustin Lobo [EMAIL PROTECTED] wrote: I've set layout(matrix(c(1,3,2,4),ncol=2)) and par(mar=c(0, 4, 4, 0) + 0.0) and par(mar=c(0, 0, 4, 3) + 0.0) for the upper-left and upper-right plots, but still get an space between both plots, is there any way to completely eliminate that space? Thanks Agus -- Dr. Agustin Lobo Institut de Ciencies de la Terra Jaume Almera (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: [EMAIL PROTECTED] http://www.ija.csic.es/gt/obster __ 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 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] spdep question - Moran's I
Dear all, I would like to calculate a Moran's I statistic using the moran function in the spdep package. The problem I'm having deals with how to create the listw object. My data stems from the area of social network analysis. I have list of poeple and for each pair of them I have a measure of their relationship strength. So my dataset looks like: Jim; Bob; 0.5 This measure of relationship strength can be interpreted like a distance measure in a spatial model. I assume that I need to work with the nb2listw function, but I am lost what to do in detail. Thanks very much for your help in advance! Michael Haenlein Assistant Professor of Marketing ESCP-EAP European School of Management Paris, 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.
[R] Vertical bars with barchart
Hallo, What is the right way to get vertical bars in a barchart? For instance barchart(VADeaths, key=simpleKey(colnames(VADeaths),points=F,rectangles=T)) gives what I need, only I would like the bars to be vertical. But barchart(VADeaths,horizontal=F, key=simpleKey(colnames(VADeaths),points=F,rectangles=T)) does not give what I need, and I do not understand how to change the dimensions accordingly. Thanks, Gerrit. -- Gerrit Draisma Department of Public Health Erasmus MC, University Medical Center Rotterdam Room AE-103 P.O. Box 2040 3000 CA Rotterdam The Netherlands Phone: +31 10 7043124 Fax: +31 10 010-7038474 http://mgzlx4.erasmusmc.nl/pwp/?gdraisma __ 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 in installing R packages on linux
man4ish wrote: No i am trying to install BART which is valid name , i have 30-40 times for other packages still facing the same pblm .How can i rectify this.Please help me out. Rather than sending a screenshot of a terminal (and note the posting guidelines with regards to attachments), if you copy and paste the text that shows the commands you are typing and the errors you are getting it will be more informative to those who you are seeking help from. Otherwise its people are just left to guess what the cause is. Neil -- View this message in context: http://www.nabble.com/problem-in-installing-R--packages-on-linux-tp16760370p16763346.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem in installing R packages on linux
On Fri, 18 Apr 2008 01:47:43 -0700 (PDT) man4ish wrote: M The screenshot is not there, but I suspect you want to install M package BARD rather than BART. M M Uwe Ligges M No i am trying to install BART which is valid name , i have 30-40 M times for other packages still facing the same pblm .How can i M rectify this.Please help me out. You are wrong. There is no BART package on CRAN. Probably you mean BART models which are in the BayesTree package: http://cran.r-project.org/web/packages/BayesTree/index.html hth Stefan __ 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] Matched pairs with two data frames
On Wed, 16-Apr-2008 at 11:58AM +0200, Udo wrote: | I only need line 1, 6 and 9. To show this, | I added needed by hand. | |age school out1 out2 needed | 11 10 9.5 1.1 yes | 21 10 9.5 2.0 no | 31 10 9.5 3.5 no | 41 10 9.5 4.9 no | 51 10 2.3 1.1 no | 61 10 2.3 2.0 yes | 71 10 2.3 3.5 no | 81 10 2.3 4.9 no | 92 20 3.3 6.5 yes | 10 2 20 4.1 6.5 no | 11 2 20 5.9 6.5 no | 12 3 33 NA 5.2 no | 13 4 11 4.6 NA no | | Whatever it is, can't you subset them out? | Yes, that´s the problem. To describe what I mean, I added the | variable needed by hand. I don´t know how to compute such a | variable to subset. | | | My final data frame should look like this: | age school out1 out2 nedded | 11 10 9.5 1.1 yes | 61 10 2.3 2.0 yes | 92 20 3.3 6.5 yes Now that I know what you want, I can see what can work. Undoubtedly, there are far more elegant ways of doing it, but this will work. xx - merge(treat, control) out - xx[1, ] # set up the out dataframe for(i in 2:nrow(xx)){ x.i - xx[i, ] kk - logical(4) for(j in 1:4) kk[j] - x.i[, j]%in%out[, j] if(!kk[4]){ # don't add to output if last column value exists if(!all(kk[1:3])) # a different combination of first 3 cols out - rbind(out, x.i) } } out age school out1 out2 1 1 10 9.5 1.1 6 1 10 2.3 2.0 9 2 20 3.3 6.5 If you have very large dataframes, you might like to improve on it. HTH -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_Middle minds discuss events (:_~*~_:)Small minds discuss people (_)-(_) . Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ 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] Vertical bars with barchart
On Fri, 18 Apr 2008 12:00:13 +0200 G. Draisma wrote: GDbarchart(VADeaths,horizontal=F, GDkey=simpleKey(colnames(VADeaths),points=F,rectangles=T)) GD does not give what I need, Works for me. Do you have the current R (2.6.2) and lattice? btw. it also works with barchart(VADeaths, horizontal=F,auto.key=T) Stefan __ 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] Working with graphs.
Hi, Im created some pie charts using R. I have two segments, I am just wondering how can I add a number to each segment that represents each each segment? Also is there a way to change the colors of each segment? Sorry if this frustrates anyone because of its simplicity, but I am new to R. Thanks in advance. BR, Jack. -- View this message in context: http://www.nabble.com/Working-with-graphs.-tp16763349p16763349.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Working with graphs.
?pie Look at the example which I think addresses most of your questions On Fri, Apr 18, 2008 at 6:31 AM, hoogeebear [EMAIL PROTECTED] wrote: Hi, Im created some pie charts using R. I have two segments, I am just wondering how can I add a number to each segment that represents each each segment? Also is there a way to change the colors of each segment? Sorry if this frustrates anyone because of its simplicity, but I am new to R. Thanks in advance. BR, Jack. -- View this message in context: http://www.nabble.com/Working-with-graphs.-tp16763349p16763349.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem 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.
Re: [R] Help with using 'get' function and variable scope
If you define your functions in the loop you can it directly since then the scoping rules work in your favor: for(i in 1:4) { f - function() i*i print(f()) } or via lapply: F - function(i) { f - function() i*i; print(f()) } lapply(1:4, F) Often the sort of situation you discuss is really an attempt to use object oriented programming without realizing it. The body of the loop is an object whose methods are the functions. The proto package http://r-proto.googlecode.com can deal with such situations as can direct manipulation of R environments or the use of function bodies as wrappers, e.g. demo(scoping) On Fri, Apr 18, 2008 at 2:00 AM, Peter Waltman [EMAIL PROTECTED] wrote: Hi Duncan - Thanks for the reply. Yeah, I understand what I'm doing is a bit weird, but I'm actually calling a few functions w/in the for-loop that need the value of the i var, and because I was a bit confused by the concept of environments, I was hoping to avoid having to pass it in as an arg to each function. Thanks, Peter On Thu, Apr 17, 2008 at 7:25 PM, Duncan Murdoch [EMAIL PROTECTED] wrote: On 17/04/2008 5:37 PM, Peter Waltman wrote: Hi - I'm having a really hard time w/understanding R's get function, and would appreciate any help with this. Specifically, I'm using a for loop to call a function. I'd like the function to have access to the variable being incremented in the for-loop, i.e. t.fn - function() return( get( i ) ) t.fn2 - function() { for ( i in 1:5 ) cat( t.fn(), \n ) } However, I keep getting err msg's from the 'get' function about how it can't find the 'i' variable. I've tried various combinations w/in the get fn, i.e. passing inherits=T (should be the default val according to R's help) and envir=sys.frame(). As I understand it, 'get' should search the enclosing environments, which I assume would be the call-stack of the functions. If not, could someone clarify? The R Language manual describes this; R uses lexical scope. get() will search the calling environment, and its parent -- which in your case is where t.fn was defined -- and the parent of that environment, etc. The call stack is not searched. There are ways to look up the stack; passing envir=parent.frame() to get will work for your needs. But it's not a natural thing to do in R; it means your t.fn wouldn't work if it was called from anywhere but t.fn2. So why not define it there, and then i would be visible to it without this trickery? I.e. t.fn2 - function() { t.fn - function() return( i ) for ( i in 1:5 ) cat( t.fn(), \n ) } Duncan Murdoch Thanks, Peter p.s. when I define t.fn to be: t.fn- function() { for ( j in sys.nframe():0 ) cat( j,:,ls( sys.frame( j ) ), \n ) } and call that in t.fn2(), I do eventually see the 'i' variable, i.e. t.fn2() 2 : j 1 : i 0 : test t.fn t.fn2 t.fn3 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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 in installing R packages on linux
install.packages(BayesTree) Is my guess for using function BART /Niels Niels Steen Krogh Konsulent ZiteLab ApS Mail: -- [EMAIL PROTECTED] Telefon: --- +45 38 88 86 13 Mobil: - +45 22 67 37 38 Adresse: --- ZiteLab ApS Solsortvej 44 dk - 2000 F. --- og --- ZiteLab ApS Refshalevej 110a dk - 1432 københavn k Web: --- www.zitelab.dk CVR: --- 29178364 Bank: -- Sparbank Vest Ejer: -- ZSRK Group Holding __ 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] RExcelInstaller
RExcelInstaller_2.0-15 installs RExcel, an add-in for Excel, which connects R and Excel. RExcel allows to transfer data between R and Excel, writing VBA macros using R as a library for Excel, and calling R functions as worksheet function in Excel. RExcel integrates nicely with R Commander (Rcmdr), turning R Commander's menus into Excel menus. It comes with a comprehensive set of example worksheet illustrating different usage scenarios. This R package installs the Excel add-in for Excel versions from 2000 to 2007. It only works on MS Windows (XP and Vista) -- Erich Neuwirth, University of Vienna Faculty of Computer Science Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-39464 Fax: +43-1-4277-39459 ___ R-packages mailing list [EMAIL PROTECTED] 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.
Re: [R] Problem with links in R website
On Thu, 17 Apr 2008 11:36:30 +0100, Robin Taylor (RT) wrote: Not sure who to send this to... On the books page http://www.r-project.org/doc/bib/R-books.html the entries from [54] down have three forward slashes in the hyperlinks to publisher info and so they don't work Thanks a lot for the bug report, fixed in the SVN archive, will go live later today. Best, Fritz -- --- Prof. Dr. Friedrich Leisch Institut für Statistik Tel: (+49 89) 2180 3165 Ludwig-Maximilians-Universität Fax: (+49 89) 2180 5308 Ludwigstraße 33 D-80539 München http://www.statistik.lmu.de/~leisch --- Journal Computational Statistics --- http://www.springer.com/180 Münchner R Kurse --- http://www.statistik.lmu.de/R __ 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] Help with using 'get' function and variable scope
On 18/04/2008 7:27 AM, Gabor Grothendieck wrote: If you define your functions in the loop you can it directly since then the scoping rules work in your favor: for(i in 1:4) { f - function() i*i print(f()) } f doesn't need to be in the loop, it just needs to be defined in the same environment as i was defined in. Loops in R don't create new local frames. Duncan Murdoch or via lapply: F - function(i) { f - function() i*i; print(f()) } lapply(1:4, F) Often the sort of situation you discuss is really an attempt to use object oriented programming without realizing it. The body of the loop is an object whose methods are the functions. The proto package http://r-proto.googlecode.com can deal with such situations as can direct manipulation of R environments or the use of function bodies as wrappers, e.g. demo(scoping) On Fri, Apr 18, 2008 at 2:00 AM, Peter Waltman [EMAIL PROTECTED] wrote: Hi Duncan - Thanks for the reply. Yeah, I understand what I'm doing is a bit weird, but I'm actually calling a few functions w/in the for-loop that need the value of the i var, and because I was a bit confused by the concept of environments, I was hoping to avoid having to pass it in as an arg to each function. Thanks, Peter On Thu, Apr 17, 2008 at 7:25 PM, Duncan Murdoch [EMAIL PROTECTED] wrote: On 17/04/2008 5:37 PM, Peter Waltman wrote: Hi - I'm having a really hard time w/understanding R's get function, and would appreciate any help with this. Specifically, I'm using a for loop to call a function. I'd like the function to have access to the variable being incremented in the for-loop, i.e. t.fn - function() return( get( i ) ) t.fn2 - function() { for ( i in 1:5 ) cat( t.fn(), \n ) } However, I keep getting err msg's from the 'get' function about how it can't find the 'i' variable. I've tried various combinations w/in the get fn, i.e. passing inherits=T (should be the default val according to R's help) and envir=sys.frame(). As I understand it, 'get' should search the enclosing environments, which I assume would be the call-stack of the functions. If not, could someone clarify? The R Language manual describes this; R uses lexical scope. get() will search the calling environment, and its parent -- which in your case is where t.fn was defined -- and the parent of that environment, etc. The call stack is not searched. There are ways to look up the stack; passing envir=parent.frame() to get will work for your needs. But it's not a natural thing to do in R; it means your t.fn wouldn't work if it was called from anywhere but t.fn2. So why not define it there, and then i would be visible to it without this trickery? I.e. t.fn2 - function() { t.fn - function() return( i ) for ( i in 1:5 ) cat( t.fn(), \n ) } Duncan Murdoch Thanks, Peter p.s. when I define t.fn to be: t.fn- function() { for ( j in sys.nframe():0 ) cat( j,:,ls( sys.frame( j ) ), \n ) } and call that in t.fn2(), I do eventually see the 'i' variable, i.e. t.fn2() 2 : j 1 : i 0 : test t.fn t.fn2 t.fn3 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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] ts.plot() labeling x-axis
Hello, I have tried a few variants of a solution from the previous posts, but perhaps my syntax is wrong. I am using ts.plot(data_as_columns) and would like the label the x axis using some labels (in my case minutes after 9am). Any ideas how to use the plot params and the Axis function to accomplish this? Any help is very appreciated. Regards, Tom == Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html == [[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] Function redefinition - not urgent, but I am curious
This is just my curiousity working. Suppose I write: f1 - function(x) x + 1 f2 - function(x) 2 * f1(x) f2(10) # 22 f1 - function(x) x - 1 f2(10) # 18 This is quite obvious. But is there any way to define f2 in such a way that we freeze the definition of f1? f1 - function(x) x + 1 f2 - function(x) # put something here 2 * f1(x) # probably put something else here too f2(10) # 22 f1 - function(x) x - 1 f2(10) # 22 - f1 inside f2 does not change Alberto Monteiro __ 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] validation of logistic regression model with weighted presences and absences
Eva Mosner wrote: Hello everyone! I want to validate logistic regression models of species distrubution data where presences and absences are weighted differently. I used lrm from Design package but unfortunately, validate.lrm ignores weights in the validation process. Has anyone an idea (package, code) how I can do the validation including weights? Thanks a lot! Eva [EMAIL PROTECTED] Code contributions to the predab.resample function in Design are welcomed. Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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] Function redefinition - not urgent, but I am curious
Try f2 - local({f1 - f1; function(x) 2 * f1(x) }) On Fri, Apr 18, 2008 at 8:22 AM, Alberto Monteiro [EMAIL PROTECTED] wrote: This is just my curiousity working. Suppose I write: f1 - function(x) x + 1 f2 - function(x) 2 * f1(x) f2(10) # 22 f1 - function(x) x - 1 f2(10) # 18 This is quite obvious. But is there any way to define f2 in such a way that we freeze the definition of f1? f1 - function(x) x + 1 f2 - function(x) # put something here 2 * f1(x) # probably put something else here too f2(10) # 22 f1 - function(x) x - 1 f2(10) # 22 - f1 inside f2 does not change Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Constrained Nelder-Mead
jangarita at ipc.com.co writes: Dear Mr, I saw by the web your request about the code in Language C of the method Nelder-Mead with constraints, I would like if you got the program, it's posible you can help us to get the code in C, This doesn't make much sense. I can imagine that you're looking for an implementation of a constrained Nelder-Mead algorithm in C. If there were one in R (which there isn't, you could pull it out of the code). You might search for COBYLA in http://www.jeannot.org/~js/code/index.en.html ... Ben Bolker __ 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] Labels in cluster nodes
Hello all, I am novice in R, I've started to work with cluster, and in the cluster i obtain: $merge [,1] [,2] [1,] -1 -2 [2,] -3 1 $height [1] 2.291288 3.834058 $order [1] 1 2 3 When i use plot, obtain (in 'chargraphics'): | --- | | | | | | --- | | | | | | | A B C and i like put in each node the cluster stage index | -2- | | | | | | ---1--- | | | | | | | AB C How do I have this dendrogram? Thank's Ramón Hidalgo [[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] Function redefinition - not urgent, but I am curious
you could define 'f1' inside 'f2' or assign 'f1' to a new environemnt (or use local()): # 1st f2 - function(x){ f1 - function(x) x + 1 2 * f1(x) } f2(10) f1 - function(x) x - 1 f2(10) # 2nd myenv - new.env() assign(f1, function(x) x + 1, myenv) f2 - function(x){ f1 - get(f1, envir = myenv) 2 * f1(x) } f1 - function(x) x - 1 f2(10) I hope it helps. Best, Dimitris Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Alberto Monteiro [EMAIL PROTECTED] To: r-help@r-project.org Sent: Friday, April 18, 2008 2:22 PM Subject: [R] Function redefinition - not urgent, but I am curious This is just my curiousity working. Suppose I write: f1 - function(x) x + 1 f2 - function(x) 2 * f1(x) f2(10) # 22 f1 - function(x) x - 1 f2(10) # 18 This is quite obvious. But is there any way to define f2 in such a way that we freeze the definition of f1? f1 - function(x) x + 1 f2 - function(x) # put something here 2 * f1(x) # probably put something else here too f2(10) # 22 f1 - function(x) x - 1 f2(10) # 22 - f1 inside f2 does not change Alberto Monteiro __ 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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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] 3-D-Plot
Edwin Sendjaja wrote: Hi Uwe, I decided to use scatterplot3d, because it looks better. I have some questions: Is it possible to get 1 axis( for example: z-axis) not as numeric, but as character. Because I have date set like this: x=relative Time: 0,3 ms; 0,5ms, etc y=Delay:10 ms, 20 ms, etc z= Host: cnn.com, heise.de,etc See ?scatterplot3d. You can use arguments x.ticklabs, y.ticklabs, z.ticklabs in order top specify character strings. If no, can you tell me little how to modify the code to get this. Thank you. another question: How can I change the width line of the axis (x,y,z). The default line is for me too thin. par(lwd=2) or more, for example. First example from ?scatterplot3d but with some other labels on x axis and thick lines: z - seq(-10, 10, 0.01) x - cos(z) y - sin(z) par(lwd=3) scatterplot3d(x, y, z, highlight.3d=TRUE, col.axis=blue, col.grid=lightblue, main=scatterplot3d - 1, pch=20, x.ticklabs=paste(seq(0.3, 1.1, by=0.2), ms), xlab=relative Time) Best wishes, Uwe Thank you in advance, Edwin Sendjaja Am Donnerstag, 17. April 2008 14:43:39 schrieb Uwe Ligges: Edwin Sendjaja wrote: Hi Uwe, Thanks for your answer. What is the different between rgl and scatterplot3d? I dont need a graphik like vulcano. I just need 3D-dot-plot. Sure, rgl can do it as well. Difference is that scatterplot3d is based on R's standard devices while rgl is based on an OpenGL device. Hence rgl is much more flexible and can rotate things and easily draws nice transparent forms, but scatterplot3d is nice for printing to 2D in different formats at the end. Uwe Am Donnerstag, 17. April 2008 09:03:17 schrieb Uwe Ligges: Edwin Sendjaja wrote: Hello, I've got some problems. I hope someone can help me. First question: I am trying to get grid on scatterplot3d (from scatterplot3d package). It seems that scatterplot3d draw on grip on X and Z side. Is it possible to get Grid on the whole Box? At least there is no build in function to do it. Second question: Is it possible to use the standard package drawing 3d-plot(without scatterplot3d) ?because now I have already 2d-plot. I just want to add the z-axis. See, for example, ?cloud in package lattice, ?plot3d in package rgl, Third question: What is the best 3d-plot? it seems that scatterplot3 doesn't support anything( like turning the box vertically. I think, angle parameter just turn the box horisontally. I might wrong with this. You are right. Best wishes, Uwe Thank a lot in advance Edwin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] space between plots
ok, I see: I was confused because the box goes a bit beyond the axes: layout(matrix(c(1,3,2,4),ncol=2)) par(mar=c(0, 4, 4, 0) + 0.0) plot(1,yaxt=n) par(mar=c(0, 0, 4, 3) + 0.0) plot(2,bty=n,yaxt=n) ...and I'm not plotting the box in my graphic. Thanks Agus jim holtman escribió: When I try this: layout(matrix(c(1,3,2,4),ncol=2)) par(mar=c(0, 4, 4, 0) + 0.0) plot(1) par(mar=c(0, 0, 4, 3) + 0.0) plot(2) plot(3) plot(4) the upper left and right are butted together. Exactly what 'space' are you talking about? On Fri, Apr 18, 2008 at 4:19 AM, Agustin Lobo [EMAIL PROTECTED] wrote: I've set layout(matrix(c(1,3,2,4),ncol=2)) and par(mar=c(0, 4, 4, 0) + 0.0) and par(mar=c(0, 0, 4, 3) + 0.0) for the upper-left and upper-right plots, but still get an space between both plots, is there any way to completely eliminate that space? Thanks Agus -- Dr. Agustin Lobo Institut de Ciencies de la Terra Jaume Almera (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: [EMAIL PROTECTED] http://www.ija.csic.es/gt/obster __ 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. -- Dr. Agustin Lobo Institut de Ciencies de la Terra Jaume Almera (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: [EMAIL PROTECTED] http://www.ija.csic.es/gt/obster __ 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] spatialpixelsdataframe
Thanks Paul, Will keep that in mind for my next query :-) Paul Hiemstra wrote: Dave Depew wrote: I have a spatialpixelsdataframe containing bathymetry data. Is it possible to save this as something similar to the meuse.grid so it can be loaded without having to run the spatial interpolation each time the script is called? I don't see a straightforward method in the sp documentation. __ 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. Hi Dave, You can save the SpatialPixelsDataFrame to a file using: save(SPDF_object, file =test.rda) And reload it with: load(test.rda) This is not specific to the sp-package. These kinds of questions are better to post to the r-sig-geo mailing list. Paul __ 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] survreg with frailty
The combination of survreg + gamma frailty = invalid model, i.e., the example that you quote. I did not realize that this had been added to the survreg help file until very recently. I will try to fix the oversight. Other, more detailed documentation states that Gaussian frailty + AIC is the only valid random effects choice for survreg. Details: frailty(x) with no optional arguments defaults to mle as the method of choosing the variance of the random effect, via a calculation that is specific to the Cox model. Terry Therneau __ 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] Help with using 'get' function and variable scope
On Fri, Apr 18, 2008 at 7:49 AM, Duncan Murdoch [EMAIL PROTECTED] wrote: On 18/04/2008 7:27 AM, Gabor Grothendieck wrote: If you define your functions in the loop you can it directly since then the scoping rules work in your favor: for(i in 1:4) { f - function() i*i print(f()) } f doesn't need to be in the loop, it just needs to be defined in the same environment as i was defined in. Loops in R don't create new local frames. That's a good point. Do you know if R will optimize out constant expressions from a loop? __ 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] vector in filename
On Thu, Apr 17, 2008 at 8:05 PM, [Ricardo Rodriguez] Your XEN ICT Team [EMAIL PROTECTED] wrote: Hi, I am trying to generate a group of graphics with an iteration. Some thing like this... x=1 y=1 max=10 myfiles - paste(foo, x:max, .png, sep=) while (x = max) { png(file=myfiles, pointsize = 20, width = 600, height = 600, units = px, bg=#eaedd5) plot(x,y) dev.off() x=x+1 y=y+1 } I am getting only one *.png file with the name of the first position in myfiles and the content of the last graphic in the iteration. Please, could you tell me if it is possible to iterate file= in any other way? Have you looked at ?png : filename: the name of the output file. The page number is substituted if a C integer format is included in the character string, as in the default. (The result must be less than 'PATH_MAX' characters long, and may be truncated if not. See 'postscript' for further details.) Tilde expansion is performed where supported by the platform. so the default filename (Rplot%03d.jpeg) already does what you want. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with using 'get' function and variable scope
On 4/18/2008 9:19 AM, Gabor Grothendieck wrote: On Fri, Apr 18, 2008 at 7:49 AM, Duncan Murdoch [EMAIL PROTECTED] wrote: On 18/04/2008 7:27 AM, Gabor Grothendieck wrote: If you define your functions in the loop you can it directly since then the scoping rules work in your favor: for(i in 1:4) { f - function() i*i print(f()) } f doesn't need to be in the loop, it just needs to be defined in the same environment as i was defined in. Loops in R don't create new local frames. That's a good point. Do you know if R will optimize out constant expressions from a loop? It doesn't. Luke Tierney's experimental byte code compiler might do optimizations like that, but the regular evaluator does very little inspection of what it is evaluating. Duncan Murdoch __ 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] Matched pairs with two data frames
Udo [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Daniel, thank you! I want to perfrom the simplest way of matching: a one-to-one exact match (by age and school): for every case in treat find ONE case (if there is one) in control . The cases in control that could be matched, should be tagged as not available or taken away (deleted) from the control pool (thus, the used ones are not replaced). #treatment group treat - data.frame(age=c(1,1,2,2,2,4), school=c(10,10,20,20,20,11), out1=c(9.5,2.3,3.3,4.1,5.9,4.6)) #control group control - data.frame(age=c(1,1,1,1,3,2), school=c(10,10,10,10,33,20), out2=c(1.1,2,3.5,4.9,5.2,6.5)) #one-to-one exat matching-alorithmus matched.data.frame - ? In my example I matched the cases by hand to make things clear. Case 1 from treat was matched with case 1 from control, 2 with 2 and 3 with 6. Case 4, 5 and 6 could not be matched, because there is no partner in control . Thus my matched example data frame has 3 cases. Is it really the case that SPSS would give the output that you describe without any warnings about non-uniqueness? How could they live with themselves after such arbitrary behavior? This link is evidence that SPSS may not behave as you allege. http://kb.iu.edu/data/afit.html If you really want to persist in what cannot possibly be called one- to-one exact matching, but instead arbitrary convenience matching, then you need to construct a function that sequentially marches through treat, grabs the first match (perhaps with something like): matched.first - merge(treat[1,],control, by= c(age,school))[1,] matched.first age school out1 out2 1 1 10 9.5 1.1 ... except that the 1's would be replaced with an index variable, then mark that control as taken perhaps by using all of the variables as identifiers, and then attempt match/marking for each successive case among (taken == FALSE) controls. -- David Winsemius __ 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 CMD check PACKAGE Error
Hi, Can anyone give me a hint on what's wrong if R CMD check PACKAGE gives me this error: Rd files with unknown encoding: FILENAME.Rd I have checked that file over and over and can't find any weired characters or some such. How can I fix this? Thanks for your time, Joh __ 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 candisc package on CRAN
I'm happy to announce the candisc package, v 0.5-9, now on CRAN. Generalized Canonical Discriminant Analysis Description This package includes functions for computing and visualizing generalized canonical discriminant analyses for a multivariate linear model. They are designed to provide low-rank visualizations of terms in a mlm via the plot method and the heplots package. The methods are described in Friendly, M. (2007). HE plots for Multivariate General Linear Models. Journal of Computational and Graphical Statistics, 16 (2), 421-444. http://www.math.yorku.ca/SCS/Papers/heplots.pdf Friendly, M. (2006). Data Ellipses, HE Plots and Reduced-Rank Displays for Multivariate Linear Models: SAS Software and Examples. Journal of Statistical Software, 17(6), 1-42. http://www.jstatsoft.org/v17/i06/ -Michael -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA ___ R-packages mailing list [EMAIL PROTECTED] 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.
Re: [R] vector in filename
Thanks Hadley, hadley wickham wrote: Have you looked at ?png : filename: the name of the output file. The page number is substituted if a C integer format is included in the character string, as in the default. (The result must be less than 'PATH_MAX' characters long, and may be truncated if not. See 'postscript' for further details.) Tilde expansion is performed where supported by the platform. so the default filename (Rplot%03d.jpeg) already does what you want. Hadley Yes, I've read this help page. But as far as I understand, this only allows to generated a paged file name, but not to include the value of a variable in the file name. Foo is a dummy name. It is only the numerical part of the name what variates in the samples above. I guess it won't be difficult to get Foo from values in a vector once I understand how the whole thing does work. Cheers, Ricardo -- Ricardo Rodríguez Your XEN ICT Team __ 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] rzinb (VGAM) and dnbinom in optim
Dear R-help gurus (and T.Yee, the VGAM maintainer) - I've been banging my head against the keyboard for too long now, hopefully someone can pick up on the errors of my ways... I am trying to use optim to fit a zero-inflated negative binomial distribution. No matter what I try I can't get optim to recognize my initial parameters. I think the problem is that dnbinom allows either 'prob' or 'mu' and I am trying to pass it 'mu'. I've tried a wrapper function but it still hangs. An example: #set up dummy data,load VGAM, which is where I am getting the zero-inflated neg binom #I get the same problem without VGAM, using dnbinom in the wrapper instead. library(VGAM) phi - 0.09 size - 0.7 munb - 72 x - rzinb(200, phi=phi, size=size, munb=munb) #VGAM can fit using vglm... but I'd like to try optim fit - vglm(x~1, zinegbinomial,trace=TRUE) VGLMlinear loop 1 : loglikelihood = -964.1915 VGLMlinear loop 2 : loglikelihood = -964.1392 VGLMlinear loop 3 : loglikelihood = -964.1392 Coef(fit) phi munb k 0.1200317 62.8882874 0.8179183 #build my wrapper function for dzinb fncZiNB - function(phi, size, munb){ + -sum(dzinb(x=x,phi=phi, size=size, munb=munb,log=TRUE))} #test the wrapper, seems to work. fncZiNB(phi=0.09, size=0.7, munb=72) [1] 969.1435 #try it in optim solut - optim(fn=fncZiNB,par=c(phi=0.09, munb=72, size=0.7),method = L-BFGS-B, hessian=TRUE) Error in dnbinom(x = x, size = size, prob = prob, log = log.arg) : argument size is missing, with no default I have the same problem with dnbinom. I'm sure I'm doing something obvious any suggestions? Session info below. Thanks in advance. Tim Howard New York Natural Heritage Program sessionInfo() R version 2.6.2 (2008-02-08) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats4splines stats graphics grDevices utils datasets methods [9] base other attached packages: [1] VGAM_0.7-6 randomForest_4.5-23 __ 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 me to debug this part of code?
I am trying to solve the integration equation, for different values of K from 4 to 25, the integration is with respect to u, Here is the equation:gamma(k/2) / ( sqrt(k-1)*gamma((k-1)/2) ) * integrate(f= (1+u^2/k-1)^(-k/2), lower=0, upper= sqrt(a^2*k/(k+1-a^2)) ) = the similar expression as te left hand except k becomes k+1 my code is below, I don't know why R keep telling me the syntax wrong but I am not clear, thanks. f-function(u,k){(1+u^2/(k-1))^(-k/2)} g-function(u,k){(1+u^2/k)^(-(k+1)/2)} for(k in 4:25){ out-uniroot(function(a){ m-exp(lgamma(k/2)-lgamma((k-1)/2))*1/sqrt(k-1) n-exp(lgamma((k+1)/2)-lgamma(k/2)*1/sqrt(k) m*integrate(f,lower=0,upper=sqrt(a^2*(k-1)/(k-a^2)),rel.tol=.Machine$double.eps^0.25) -n*integrate(g,lower=0,upper=sqrt(a^2*k/(k+1-a^2)),rel.tol=.Machine$double.eps^0.25) } lower=1.4, upper=2) print(unlist(out))} -- View this message in context: http://www.nabble.com/help-me-to-debug-this-part-of-code--tp16763482p16763482.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems with R2WinBUGS
Hello, Further to my previous e-mail, I think I know why I am having problems with the initialization of model parameters in R2WinBUGS. My model.bug file contains a portion of code which defines some pairwise odds ratios (e.g., or[1,2], or[1,3], or[1,4], or[2,3], or[2,4], or[3,4]) as seen below: for (c in 1:(NT-1)) { for (k in (c+1):NT) { or[c,k] - log(d[k] - d[c]) } } Apparently, R2WinBUGS can't recognize these values because they form an incomplete matrix. In trying to solve this issue, I arrived at the conclusion that R2WinBUGS may not be able to recognize WinBUGS parameters specified as a matrix (be it complete or incomplete). Is my understanding correct? Any thoughts on how to overcome this predicament would be greatly appreciated. (Thank you very much to Peter Alspach for helping me to narrow down this problem.) Many thanks! Isabella Isabella R. Ghement, Ph.D. Ghement Statistical Consulting Company 301-7031 Blundell Road, Richmond, B.C., Canada, V6Y 1J5 Tel: 604-767-1250 Fax: 604-270-3922 E-mail: [EMAIL PROTECTED] Web: [2]www.ghement.ca References 1. mailto:[EMAIL PROTECTED] 2. http://www.ghement.ca/ __ 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] rzinb (VGAM) and dnbinom in optim
I'm not going to look into what's happening in-depth but it looks like the bounds for your parameters need to be set with care; the below (with slight re-def. of your residual function) gives results that seem to match vglm approximately, with 1e-10 standing in for a bound of 0 and 1-e-10 standing in for a bound of 1. library(VGAM) phi - 0.09 size - 0.7 munb - 72 x - rzinb(200, phi=phi, size=size, munb=munb) fit - vglm(x~1, zinegbinomial,trace=TRUE) fncZiNB - function(xx, x){ phi - xx[1] size - xx[2] munb - xx[3] -sum(dzinb(x=x,phi=phi, size=size, munb=munb,log=TRUE)) } solut - optim(fn=fncZiNB,par=c(0.09, 72, 0.7),x=x,method = L-BFGS-B, lower=c(1e-10,1e-10,1e-10),upper=c(1-1e-10,Inf,Inf), control=list(trace=TRUE),hessian=TRUE) ##optim solut$par ##vglm Coef(fit) On Fri, 18 Apr 2008, Tim Howard wrote: Dear R-help gurus (and T.Yee, the VGAM maintainer) - I've been banging my head against the keyboard for too long now, hopefully someone can pick up on the errors of my ways... I am trying to use optim to fit a zero-inflated negative binomial distribution. No matter what I try I can't get optim to recognize my initial parameters. I think the problem is that dnbinom allows either 'prob' or 'mu' and I am trying to pass it 'mu'. I've tried a wrapper function but it still hangs. An example: #set up dummy data,load VGAM, which is where I am getting the zero-inflated neg binom #I get the same problem without VGAM, using dnbinom in the wrapper instead. library(VGAM) phi - 0.09 size - 0.7 munb - 72 x - rzinb(200, phi=phi, size=size, munb=munb) #VGAM can fit using vglm... but I'd like to try optim fit - vglm(x~1, zinegbinomial,trace=TRUE) VGLMlinear loop 1 : loglikelihood = -964.1915 VGLMlinear loop 2 : loglikelihood = -964.1392 VGLMlinear loop 3 : loglikelihood = -964.1392 Coef(fit) phi munb k 0.1200317 62.8882874 0.8179183 #build my wrapper function for dzinb fncZiNB - function(phi, size, munb){ + -sum(dzinb(x=x,phi=phi, size=size, munb=munb,log=TRUE))} #test the wrapper, seems to work. fncZiNB(phi=0.09, size=0.7, munb=72) [1] 969.1435 #try it in optim solut - optim(fn=fncZiNB,par=c(phi=0.09, munb=72, size=0.7),method = L-BFGS-B, hessian=TRUE) Error in dnbinom(x = x, size = size, prob = prob, log = log.arg) : argument size is missing, with no default I have the same problem with dnbinom. I'm sure I'm doing something obvious any suggestions? Session info below. Thanks in advance. Tim Howard New York Natural Heritage Program sessionInfo() R version 2.6.2 (2008-02-08) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats4splines stats graphics grDevices utils datasets methods [9] base other attached packages: [1] VGAM_0.7-6 randomForest_4.5-23 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Overall p-value from a factor in a coxph fit
Paul Johnson wrote: On Fri, Apr 18, 2008 at 3:06 AM, Kåre Edvardsen [EMAIL PROTECTED] wrote: Hi all. If I run the simple regression when x is a categorical variable ( x - factor(x) ): MyFit -coxph( Surv(start, stop, event) ~ x ) How can I get the overall p-value on x other than for each dummy variable? anova(MyFit) does NOT provide that information as previously suggested on the list. It should work... Here's a self contained example showing that anova does give the desired significance test for an lm model. y - rnorm(100) x - gl(5,20) mod - lm(y~x) anova(mod) Analysis of Variance Table Response: y Df Sum Sq Mean Sq F value Pr(F) x 4 6.575 1.644 1.5125 0.2047 Residuals 95 103.237 1.087 If you provide a similar self contained example leading up to a coxph, I would be glad to investigate your question. You don't give enough information for me to tell which version of coxph you are running, and from what package. Suppose I guess that you are using the coxph from the package survival. If so, it appears to me there is a bug in that package at the moment. The methods anova.coxph and drop1.coxph did exist at one time, until very recently. There is a thread in r-help (which I found by typing RSiteSearch(anova.coxph) ) discussing recent troubles with anova.coxph. http://finzi.psych.upenn.edu/R/Rhelp02a/archive/118481.html As you see from the discussion in that thread, there used to be an anova method for coxph, and in the version of survival I have now, there is no such method. The version I have is 2.34-1, Date: 2008-03-31. Here's what I see after I run example(coxph) in order to create some coxph objects, on which I can test the diagnostics: drop1(test2) Error in terms.default(terms1) : no terms component anova(test2) Error in UseMethod(anova) : no applicable method for anova In that survival package, I do find anova.survreg, but not anova.coxph. If you are using the survival package, I'd suggest you contact Thomas Lumley directly, since he maintains it. I think if you had reported the exact error you saw, it would have been easier for me to diagnose the trouble. HTH pj In the meantime you can do library(Design) f - cph( . . . ) anova(f) # multiple d.f. Wald statistics including tests of nonlinearity cph uses coxph but anova.Design is separate from the survival package. Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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] help me to debug this part of code?
On Fri, 18 Apr 2008, jinjin wrote: I am trying to solve the integration equation, for different values of K from 4 to 25, the integration is with respect to u, Here is the equation:gamma(k/2) / ( sqrt(k-1)*gamma((k-1)/2) ) * integrate(f= (1+u^2/k-1)^(-k/2), lower=0, upper= sqrt(a^2*k/(k+1-a^2)) ) = the similar expression as te left hand except k becomes k+1 my code is below, I don't know why R keep telling me the syntax wrong but I am not clear, thanks. First, you should format your code so that it is more readable. Use spaces and indentation. Second, it is recommended that use an editor that features syntax highlighting to prepare your code. It will show you which parentheses and braces match. And if it features automatic indentation, this will give you clues when the nesting of an expression or arglist has gone awry. Third, read the error messages that R provides and try to understand why R is telling you unexpected symbol, etc. Often, an error immediately preceeded the point at which R got confused. If all this fails, break apart your code into single expressions (or pieces you ***think*** are valid expressions) and try to evaluate them. For example, m-exp(lgamma(k/2)-lgamma((k-1)/2))*1/sqrt(k-1) is correctly parsed. It only fails for me because I tried to evaluate it without providing a value for 'k'. HTH, Chuck f-function(u,k){(1+u^2/(k-1))^(-k/2)} g-function(u,k){(1+u^2/k)^(-(k+1)/2)} for(k in 4:25){ out-uniroot(function(a){ m-exp(lgamma(k/2)-lgamma((k-1)/2))*1/sqrt(k-1) n-exp(lgamma((k+1)/2)-lgamma(k/2)*1/sqrt(k) m*integrate(f,lower=0,upper=sqrt(a^2*(k-1)/(k-a^2)),rel.tol=.Machine$double.eps^0.25) -n*integrate(g,lower=0,upper=sqrt(a^2*k/(k+1-a^2)),rel.tol=.Machine$double.eps^0.25) } lower=1.4, upper=2) print(unlist(out))} -- View this message in context: http://www.nabble.com/help-me-to-debug-this-part-of-code--tp16763482p16763482.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ 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 in installing R packages on linux
On Fri, Apr 18, 2008 at 1:28 PM, Niels Steen Krogh [EMAIL PROTECTED] wrote: install.packages(BayesTree) What is the error message? Liviu __ 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] efficiently replacing values in a matrix
Still it is pretty slow when entering values into a large matrix. Case in point: a - matrix(nrow=1,ncol=1) system.time(a[1,1] - 1903908.80385) user system elapsed 30.840 6.226 41.416 is.matrix(a) [1] TRUE Is there a better way to enter values into large matrices? If I have to spend 41 secs each time I enter into a cell and I have 1x1 cells to enter that is impractical! --Nnamdi Rolf Turner-3 wrote: On 17/04/2008, at 9:33 AM, Charles C. Berry wrote: snip I'll lay odds that Matthew's 'matrix' is actually a data.frame, and I'll not be surprised if the columns are factors. snip I suspect that you're right. ***Why*** can't people distinguish between data frames and matrices? If they were the same expletive deleted thing, there wouldn't be two different terms for them, would there? cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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. -- View this message in context: http://www.nabble.com/efficiently-replacing-values-in-a-matrix-tp16732795p16763578.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Legend Clipping
Here is a better example. I am also trying to put gaps between the bars on the graphs, and this work-around is the only way I can make it work satisfactorily. Any suggestions about that? windows(); nf - layout(matrix(c(1,2,5,0,3,4),3,2,byrow=TRUE), c(2.2,2.2), c(2.2,1,2.2), TRUE) layout.show(nf); par(font.axis=2); par(font.lab=2); ylimit=c(0,1.2); pmn - matrix(c(1:5), nrow=5, ncol=1) pmn[,1]=c(0,0.8,0,0.75,0); barplot(pmn,ylab=Slopes,beside=TRUE,ylim=ylimit,xlim=c(1,6.0), col = c(NA,blue, NA, red,NA)); par(font.axis=2); par(font.lab=2); ylimit=c(0,1.2); pmn - matrix(c(1:5), nrow=5, ncol=1) pstd=pmn; pmn[,1]=c(0,0.8,0,0.75,0); barplot(pmn,ylab=Slopes,beside=TRUE,ylim=ylimit,xlim=c(1,6.0), col = c(NA,blue, NA, red,NA)); par(font.axis=2); par(font.lab=2); ylimit=c(0,1.2); pmn - matrix(c(1:5), nrow=5, ncol=1) pstd=pmn; pmn[,1]=c(0,0.8,0,0.75,0); barplot(pmn,ylab=Slopes,beside=TRUE,ylim=ylimit,xlim=c(1,6.0), col = c(NA,blue, NA, red,NA)); par(font.axis=2); par(font.lab=2); ylimit=c(0,1.2); pmn - matrix(c(1:5), nrow=5, ncol=1) pstd=pmn; pmn[,1]=c(0,0.8,0,0.75,0); barplot(pmn,ylab=Slopes,beside=TRUE,ylim=ylimit,xlim=c(1,6.0), col = c(NA,blue, NA, red,NA)); plot(1, type=n, axes=FALSE, xlab=, ylab=,ylim=c(0,2),xlim=c(0,2)); legend(0.5,0.5, legend = c(CPX,Home), bty=n, fill=c(blue,red),lwd=1, cex=1, xjust=0.5, yjust=0.4); -Original Message- To: r-help@r-project.org Subject: [R] Legend Clipping I am having trouble with legends clipping, not sure how to control that. Here is my latest code to demo. I want the legend to show up in the center of the window, in fairly large font. Right now, font is too small, but if I increase it, the legend clips even more. In this simplified example, the plots are dummy (I took them from an example), my actual plots only have two bars, corresponding to the legend. windows(); nf1 - layout(matrix(1), widths=lcm(6), heights=lcm(6)) nf - layout(matrix(c(1,2,5,0,3,4),3,2,byrow=TRUE), c(2.2,2.2), c(2.2,1,2.2), TRUE) layout.show(nf); # par(mfrow=c(3,2)); par(font.axis=2); par(font.lab=2); # pmn=t(pmn); tN - table(Ni - stats::rpois(100, lambda=5)) barplot(tN, col=rainbow(20)) # par (mfg=c(1,2)); par(font.axis=2); par(font.lab=2); tN - table(Ni - stats::rpois(100, lambda=5)) barplot(tN, col=rainbow(20)) # par (mfg=c(2,1)); par(font.axis=2); par(font.lab=2); tN - table(Ni - stats::rpois(100, lambda=5)) barplot(tN, col=rainbow(20)) # par (mfg=c(2,2)); par(font.axis=2); par(font.lab=2); tN - table(Ni - stats::rpois(100, lambda=5)) barplot(tN, col=rainbow(20)) # par (mfg=c(3,1)); plot(1, type=n, axes=FALSE, xlab=, ylab=,ylim=c(0,2),xlim=c(0,2)); # legend(1,0.8, legend = c(CPX,Home), bty=n, fill=c(blue,red),lwd=1, cex=1, xjust=0.5, yjust=0.4); # ltest=legend(center, legend = c(CPX,Home), bty=n, fill=c(blue,red),lwd=1, cex=1, xjust=0.5, yjust=0.4,trace=TRUE,plot=FALSE); legend(0.5,0.5, legend = c(CPX,Home), bty=n, fill=c(blue,red),lwd=1, cex=1, xjust=0.5, yjust=0.4); __ 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] Fw: efficiently replacing values in a matrix
- Forwarded Message From: Nnamdi [EMAIL PROTECTED] To: roger koenker [EMAIL PROTECTED] Sent: Friday, April 18, 2008 1:08:58 PM Subject: Re: [R] efficiently replacing values in a matrix I tried the sparse matrix implementation, still there are issues: a - matrix(nrow=1,ncol=1) a.csr - as.matrix.csr(a) Error in if (nnz == 0) { : missing value where TRUE/FALSE needed I'm guessing this error here is because 'a' matrix is initialized with'NA's. Yet when I try initializing 'a' matrix with 0s I get: a-matrix(nrow=1,ncol=1,rep(0,1*1)) Error: cannot allocate vector of size 762.9 Mb Either way I cannot achieve my goal of being able to efficiently enter values into this matrix. To answer your previous question, this matrix is somewhat dense. It is a symmetrical matrix thus only the upper triangle is filled. Any other ideas? Thanks again --Nnamdi - Original Message From: roger koenker [EMAIL PROTECTED] To: Nnamdi [EMAIL PROTECTED] Sent: Friday, April 18, 2008 12:25:54 PM Subject: Re: [R] efficiently replacing values in a matrix is this really a dense matrix? if not, then sparse representations would be much more efficient... url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 On Apr 18, 2008, at 12:11 PM, Nnamdi wrote: Still it is pretty slow when entering values into a large matrix. Case in point: a - matrix(nrow=1,ncol=1) system.time(a[1,1] - 1903908.80385) user system elapsed 30.840 6.226 41.416 is.matrix(a) [1] TRUE Is there a better way to enter values into large matrices? If I have to spend 41 secs each time I enter into a cell and I have 1x1 cells to enter that is impractical! --Nnamdi Rolf Turner-3 wrote: On 17/04/2008, at 9:33 AM, Charles C. Berry wrote: snip I'll lay odds that Matthew's 'matrix' is actually a data.frame, and I'll not be surprised if the columns are factors. snip I suspect that you're right. ***Why*** can't people distinguish between data frames and matrices? If they were the same expletive deleted thing, there wouldn't be two different terms for them, would there? cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid... {{dropped:9}} __ 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. -- View this message in context: http://www.nabble.com/efficiently-replacing-values-in-a-matrix-tp16732795p16763578.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Be a better friend, newshound, and Be a better friend, newshound, and __ 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] efficiently replacing values in a matrix
Nanmdi, I think this is simply because a lot of time is taken transforming the matrix from logical (default when you create it) to numeric (when you add the number to [1,1]. If you do the same thing again to [1,2], it is done instantaneously: a - matrix(nrow=1,ncol=1) system.time(a[1,1] - 1903908.80385) user system elapsed 10.000 0.781 10.755 system.time(a[1,2] - 1903908.80385) user system elapsed 0 0 0 By the way Rolf - I didn't see your full response last time through. I do know the difference between a matrix and a data.frame, thank you very much. On Fri, Apr 18, 2008 at 11:11 AM, Nnamdi [EMAIL PROTECTED] wrote: Still it is pretty slow when entering values into a large matrix. Case in point: a - matrix(nrow=1,ncol=1) system.time(a[1,1] - 1903908.80385) user system elapsed 30.840 6.226 41.416 is.matrix(a) [1] TRUE Is there a better way to enter values into large matrices? If I have to spend 41 secs each time I enter into a cell and I have 1x1 cells to enter that is impractical! --Nnamdi Rolf Turner-3 wrote: On 17/04/2008, at 9:33 AM, Charles C. Berry wrote: snip I'll lay odds that Matthew's 'matrix' is actually a data.frame, and I'll not be surprised if the columns are factors. snip I suspect that you're right. ***Why*** can't people distinguish between data frames and matrices? If they were the same expletive deleted thing, there wouldn't be two different terms for them, would there? cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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. -- View this message in context: http://www.nabble.com/efficiently-replacing-values-in-a-matrix-tp16732795p16763578.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Matthew C Keller Asst. Professor of Psychology University of Colorado at Boulder www.matthewckeller.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RPy
I'm curious if there are users of RPy on this list. I've recently created a gui front end using Tkinter for some python scripts I've written for some of our internal operations and I am quite pleased with how this program works. I wonder if it is possible to also get this gui to run R functions through the use of RPy. Going even a step further, I wonder if it is possible to get this program to run R functions withouth even having R installed on the machine. Currently, I can use py2exe to create a executable that allows for this gui to appear and for all python scripts to run even if the user doesn't have python on their machine. So (maybe) in theory if I can link Rpy to my gui to run R, I can then use py2exe to compile it and that would allow the user to run the functions even if R isn't on the machine. I realize this is a broad question and has no minimal commented code. But, if anyone has some experience using Rpy, Tkinter and R I can come up with a small example to see if we could work out a possible way to use Tkinter to run R. [[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] Correspondence and detrended correspondence analysis
Hi, I hope someone knows the answer to this or has a real good reference about it (I am using Legendre Legendre, Numerical Ecology, 1998) My data is a data.frame with locations as rows and vegetation assemblages / species as columns. I've done a PCA, a correspondance analysis (CA) using ca in ca package and a detrended correspondance analysis (DCA) using decorana from vegan package. As far as i understand what i've done the relationships between vegetation categories and locations should be similar in all 3 analysis, although the 'arch' in locations / sites seen in the CA plot should be flatten out by the DCA - which it is!. My problem is that the locations / sites are flipped in the DCA plot versus PCA or CA plots (locations with positive coordinates now have negative coordinates in DCA versus CA or PCA), although the vegetation categories keep same relationships between them in all three plots - which is expected. If some code is required i can provide it but i didn't want to clutter the message too much. But i am providing the resulting plots in case they will make my problem clearer. PCA plot: ftp://stpfiles.er.usgs.gov/Monica/R_Data/pca_veg_lidarclass_phase2.pdf CA plot: ftp://stpfiles.er.usgs.gov/Monica/R_Data/corresp_anal_phase2.pdf DCA plot: ftp://stpfiles.er.usgs.gov/Monica/R_Data/detrend_corresp_anal_phase2.pdf DCA how i would expect it: ftp://stpfiles.er.usgs.gov/Monica/R_Data/detrend_corresp_anal_phase2_a.pdf Any thoughts on this will be very much appreciated, Monica _ esh_getintouch_042008 __ 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] Embedding fonts in pdfs
Hi all, I'm having problems embedding fonts in my graphics - and I've tried embedFonts to no avail. I have a pdf file and pdffonts tells me: name type emb sub uni object ID - --- --- --- - ZapfDingbats Type 1no no no 5 0 HelveticaType 1no no no 10 0 (both before and after running the gs script). From reading the documentation, I suspect that these aren't being embedded because they are standard PS fonts, but my publisher (lulu.com) wants them embedded. Does anyone have any hints? Thanks, Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Embedding fonts in pdfs
hadley wickham wrote on 04/18/2008 02:40 PM: Hi all, I'm having problems embedding fonts in my graphics - and I've tried embedFonts to no avail. I have a pdf file and pdffonts tells me: name type emb sub uni object ID - --- --- --- - ZapfDingbats Type 1no no no 5 0 HelveticaType 1no no no 10 0 (both before and after running the gs script). From reading the documentation, I suspect that these aren't being embedded because they are standard PS fonts, but my publisher (lulu.com) wants them embedded. Does anyone have any hints? Have you tried using the Cairo package? For instance, I just helped one of our users here at Vanderbilt to embed 'Gill Sans MT' (because apparently it's required by some journal) into her PDF graphic, like so: CairoFonts( regular=Gill Sans MT, bold=Gill Sans MT:style=Bold, italic=Gill Sans MT:style=Italic, bolditalic=Gill Sans MT:style=Bold Italic ) CairoPDF(file=file.pdf) ... dev.off() Also, Preview or even Acrobat reader (or xpdf) should reveal in the Properties of the pdf file whether or not your desired fonts are embedded. Best, Jeff -- 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] using rbind() on multiple objects at once
do.call(rbind, list.foo) On Fri, 18 Apr 2008, Andrew Yee wrote: Is there an efficient way to use rbind() with the five dataframes described in the following example: a - c(1:5) list.foo - lapply(a, function(x) data.frame(beta=a*rnorm(10), deta=a*rnorm(10))) big.data.frame - rbind(list.foo[[1]], list.foo[[2]], list.foo[[3]], list.foo[[4]], list.foo[[5]]) #is there an easier method? For example, I naively thought you could do something like rbind(list.foo[[1:5]]) #gives an error message but that results in an error message. Thanks, Andrew [[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.
Re: [R] Response to R across the university
On 18 Apr 2008, at 6:42 pm, Peter Dalgaard wrote: Antony Unwin wrote: ... The course itself went very well. We encouraged people to bring their laptops and work in groups. Using JGR as the interface to R helped a lot, as it was easier for people to load their own data and use the help. Of course, JGR is compulsory in Augsburg. Speaking of JGR... What are the appropriate channels to complain and/ or contribute? This will do fine, though [EMAIL PROTECTED] would be the official route and Markus Helbig ([EMAIL PROTECTED]) is the key person. I had looked into it at an earlier point (on Fedora Linux) and got stuck on some fairly simple usability issues, like font choice and color scheme. Things like - if you select a bigger font, the window size remains the same. Changes to window size do not survive to subsequent invokations. - output is quite unreadable in proportional fonts, so why make them available? - some fonts have poor contrast, but there seems to be no way to select boldface versions. - the latest version has turned to a blue-on-gray scheme, which doesn't help with the contrast either This is all pretty trivial stuff, but the bottom line is that all the really exciting stuff isn't really of much use if students cannot read it in the back rows. Your points should certainly be looked into. Having the font big enough for students to read in the back row has not been a problem for me. A couple other maybe not all that trivial things to do is to improve the data import (it is losing out on most of the things that I tried) Now what would Brian say to a comment like that? Please insert your favourite put-down here: And then perhaps you would be kind enough to let us know in a little more detail what hasn't worked for you. and to get the wires connected between the DataTable and the edit() command. Thanks for your comments. Antony [[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] Line-wrap problem
I'm wondering if someone can tell me how R determines where to wrap lines in its output. I'd like to understand this because occasionally often after running a script the output of R no longer wraps at the correct location. For example, the statement, '1:40' would ordinarily return something like this... [1]1 2 34 5 6 78 9 10 11 12 13 14 15 16 17 18 19 20 [21] 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 and is instead returning longer lines like this... [1]1 2 34 5 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 As you can imagine this makes it hard to read output because the results no longer line up in nice columns. This seems to happen without my having resized the window but resizing the window can occasionally make it better. Thanks, Matthew Other details: System: Mac OS X v.10.4.11 Running R from command line (Terminal.app) or from R.app __ 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] 2.2e-16 a magic number? ks.test help
Hello, I'm trying to test my data for normality. I enter the data (95ish species counts) run ks.test (data,pnorm) and get a p- value 2.2e-16 But this seems to be the p-value no matter what the data I enter. (I have multiple datasets and am testing them all for normality). [Actually, I just entered a vector of 1's and the p-value changed.] When I use the Shapiro.test command, I get different p-values (different from each other as well as from the ks.test results), and in fact one variable that was significantly different from normal using the ks.test (p2.2e-16), is not significantly different from normal using the Shapiro.test (p=0.2389). I am happy to believe that all my data are not normally distributed, but am just suspicious when the p-value remains the same regardless of the data (including log and sqrt transformed data). Is 2.2e-16 simply the lowest the p-values can go + my data are just really not normal? Any help much appreciated. Thanks, Gail __ 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] Response to R across the university
Antony Unwin wrote: A couple other maybe not all that trivial things to do is to improve the data import (it is losing out on most of the things that I tried) Now what would Brian say to a comment like that? Please insert your favourite put-down here: He'd usually say something about reproducible examples, just like you... Don't get me wrong. I realize that the Open dialog in DataTable is designed to read one, simple data format, not all of them. I just couldn't easily figure out which one that was. And then perhaps you would be kind enough to let us know in a little more detail what hasn't worked for you. Anything in the data directory of the ISwR package, for instance (whitespace separated and comma separated files, mostly). I suspect that the format it _will_ read is TAB separated, but it would be nice if it said so somewhere. (Curiously, thuesen.txt does have tabs, but not equally many in the header as in the data lines, so it can't be read at all, the others just get all fields and headers jammed into one.) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] help me to debug this part of code?
There are a lot of syntax errors such as unclosed parentheses, missing commas etc; Example: exp@(@lgamma((k+1)/2)-lgamma(k/2)*1/sqrt(k), where the parenthesis between the @s is not closed. I suggest you get an editor such as Tinn that can highlight those for you. In addition I notice that you use two functions: f and g, in a loop but you didn't pass any arguments to them. jinjin wrote: I am trying to solve the integration equation, for different values of K from 4 to 25, the integration is with respect to u, Here is the equation:gamma(k/2) / ( sqrt(k-1)*gamma((k-1)/2) ) * integrate(f= (1+u^2/k-1)^(-k/2), lower=0, upper= sqrt(a^2*k/(k+1-a^2)) ) = the similar expression as te left hand except k becomes k+1 my code is below, I don't know why R keep telling me the syntax wrong but I am not clear, thanks. f-function(u,k){(1+u^2/(k-1))^(-k/2)} g-function(u,k){(1+u^2/k)^(-(k+1)/2)} for(k in 4:25){ out-uniroot(function(a){ m-exp(lgamma(k/2)-lgamma((k-1)/2))*1/sqrt(k-1) n-exp(lgamma((k+1)/2)-lgamma(k/2)*1/sqrt(k) m*integrate(f,lower=0,upper=sqrt(a^2*(k-1)/(k-a^2)),rel.tol=.Machine$double.eps^0.25) -n*integrate(g,lower=0,upper=sqrt(a^2*k/(k+1-a^2)),rel.tol=.Machine$double.eps^0.25) } lower=1.4, upper=2) print(unlist(out))} -- View this message in context: http://www.nabble.com/help-me-to-debug-this-part-of-code--tp16763482p16765605.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in Merge?
Edwin Sendjaja wrote: Hello, I find strange number in my merge data set. My first coloumn consist row numbers. --- my.data: AbsTime RelTime PE_IDEvent Delay 4238 1208514343.812086107.153637 4 EKA 51620 ## Host.data: ID Host 4 4vicky.planetlab.ntua.gr data-read.table(my.data) mapping-read.table(Host.data) mergeXY - merge(data,mapping, by.x=PE_ID, by.y=ID) If I merge these data then i get: PE_ID AbsTime RelTime Ereignis Delay Host 2 4 1208514343.81209 107.153637 EndpointKeepAlive 51620 vicky.planetlab.ntua.gr --- The first problem: Why is the row number 2 now? Where does this nummber come from? I don't know. Where did Ereignis and EndpointKeepAlive come from That is, you are paraphrasing your results instead of giving us a reproducible example to go on! (And I can't reproduce it. I get a rowname of 1, whatever I try.) I think, there is a conflict between my row number from data and mapping (4238 and 4). The second problem: Why is my AbsTime: 1208514343.81209? It was 1208514343.812086. It is 1 digit less. how can I avoid this? You're running out of floating point precision (the rel. error is about 1e-16). Either user fewer digits (e.g. move the origin of time 120850 units forward) or don't represent as floating point. Using colClasses, you can read it as a character variable and take it from there. One idea is to represent the integer and fractional parts separately. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] Distribution Graph Idea/Help
For pedagogical reasons (i.e., moving a way from tables of distributions) I want to plot a probability density or distribution function with a shaded area corresponding to the calculated value or user input. For example, I want a plot to visually demonstrate the result of pnorm(1.3) I have seen the interactive examples in TeachingDemos and rPanel but am interested in using the function from the command line rather than from a GUI. I have generated code to construct this type of graph, but my question is now how best to implement it. My initial solution was to add a plot=TRUE argument to pnorm() but that requires altering a base function and I now think that this is not a good idea (although it worked nicely from the student's perspective). Thus, I have considered three new options ... 1) making a new function called something like pnorm1() which would return what pnorm() returns but also would construct the graphic. This implementation would be simple given the function that I have already made but it feels clumsy and inelegant. 2) creating a generic plot() function that would take, for example, an object returned from pnorm(). However, this does not seem immediately possible as, it appears to me, that pnorm() just returns a numeric. 3) creating a general function that would take the name of a distribution, type of calculation (p or q type), value of interest (x value or probability), and distribution parameters as arguments and then call the specific distribution functions and my graphing function to produce the results. I would likely implement this just for distributions that I use regularly in my classes. Has anybody already implemented a solution to this idea? Does anyone have a suggestion on which of my three options above is best for this code? Better ideas? Thanks in advance for any help. __ 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 JGR_1.5-18
R version 2.7.0 Under development (unstable) (2008-03-04 r44677) i386-apple-darwin8.10.1 locale: C attached base packages: [1] grid grDevices datasets graphics stats utils methods base other attached packages: [1] lattice_0.17-6 MASS_7.2-41JGR_1.5-18 iplots_1.1-2 JavaGD_0.5-1 rJava_0.5-1 The following opens a JavaGD window and freezes JGR: super.sym - trellis.par.get(superpose.symbol) (from splom help page). _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ [[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] How to insert a vector or matrix into an existing matrix
Hi, Is there any functions to insert a vector or matrix into an existing matrix say between row 5 and 6 or column 8 and 9, without creating a temporary matrix ? Thanks Stanley [[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] eval and parent.frame [was: Error in Design package: dataset not found for options(datadist)]
Charles C. Berry wrote: On Fri, 18 Apr 2008, Gad Abraham wrote: Frank E Harrell Jr wrote: Gad Abraham wrote: Hi, Design isn't strictly an R base package, but maybe someone can explain the following. When lrm is called within a function, it can't find the dataset dd: library(Design) age - rnorm(30, 50, 10) cholesterol - rnorm(30, 200, 25) ch - cut2(cholesterol, g=5, levels.mean=TRUE) fit - function(ch, age) + { +d - data.frame(ch, age) +dd - datadist(d) +options(datadist=dd) +lrm(ch ~ age, data=d, x=TRUE, y=TRUE) + } fit(ch, age) Error in Design(eval(m, sys.parent())) : dataset dd not found for options(datadist=) It works outside a function: d - data.frame(ch, age) dd - datadist(d) options(datadist=dd) l - lrm(ch ~ age, data=d, x=TRUE, y=TRUE) Thanks, Gad My guess is that you'll need to put dd in the global environment, not in fit's environment. At any rate it is inefficient to call datadist every time. Why not call it once for the whole data frame containing all the predictors, at the top of the program? This is just sample code, in practice the datadist will be different for each invocation of the function. I think it boils down to this behaviour, which I don't understand --- although ls can see x in the parent of f2, eval cannot: That is because (from ?eval): Objects to be evaluated can be of types call or expression or name (when the name is looked up in the current scope and its binding is evaluated)... And 'x' is of type name (aka 'symbol'). So eval never gets around to looking in 'p', because it never succeeded in looking up 'x' and evaluating its binding in the current scope. What you probably want is b - evalq( x, envir=p) Thanks, that solves the problem with this sample code, but not with the Design::lrm function, because there are several more layers of evaluation there. I can get around that with the ugly hack of setting a global NULL datadist and assigning to it with - within the fit function every time, so it's always visible to Design. But it's still an ugly hack :) -- Gad Abraham Dept. CSSE and NICTA The University of Melbourne Parkville 3010, Victoria, Australia email: [EMAIL PROTECTED] web: http://www.csse.unimelb.edu.au/~gabraham __ 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.