Re: [Rd] residuals.glm for glm(..., y = FALSE)
On Mon, 24 Jul 2006, Achim Zeileis wrote: I just ran into a problem with residuals.glm() for GLMs fitted with glm(..., y = FALSE) For such fits, the residuals of type deviance, pearson and response can't be computed (see example below). The reason is that residuals.glm() uses y - object$y which obviously can't work for such fits. I've checked ?glm and ?residuals.glm and did not find it mentioned explicitely...looks like a bug to me. Well, the original S code returns numeric(0): surely that is worse. There is not enough information in the fit to recover the response residuals in general (the problem I see is with zero weights), so all we can do it throw an informative error. Best, Z ## example for poisson GLM from ?glm d.AD - data.frame(treatment = gl(3,3), outcome = gl(3,1,9), counts = c(18,17,15,20,10,20,25,13,12)) glm.D93 - glm(counts ~ outcome + treatment, family = poisson, data = d.AD, y = FALSE) ## residuals cannot be computed residuals(glm.D93, type = deviance) residuals(glm.D93, type = pearson) residuals(glm.D93, type = response) __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- 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-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] dev.copy()
VĂctor Llorens Vilella wrote: Hello, anybody knows dev.copy() usage? I'm developing a GUI for R, and at some time when I have a plot, I want to save it as a pdf. dev.copy() is , I think, what I need as well as open a pdf() device. Well, dev.copy(pdf, .) should do it itself. There is an example on the help page ?dev.copy. So: What is difficult here (it is hard for us to anticipate what you are not understanding)? What about giving an example of code that shows how you undertsood that page, so we can try to correct. Uwe Ligges I have read lot of times help(dev.dopy) but It's a little difficult to understand :S Any idea? __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R::Rdconv Rdconv() does not close input file handle (PR#9126)
Bill, Thanks for the report. It looks like the mail system has mangled the patches, but I have applied them manually to 2.3.1 patched and R-devel. Brian On Sat, 5 Aug 2006, [EMAIL PROTECTED] wrote: Full_Name: Bill Dunlap Version: 2.3.0 OS: Windows XP Submission from: (NULL) (71.121.183.214) If you had an Rd file called file.Rd and write a perl script containing print Before Rdconv: ; system /usr/sbin/lsof | grep $USER | grep Rd; Rdconv(file.Rd, , example, ../R-ex/file.R); print After Rdconv: ; system /usr/sbin/lsof | grep $USER | grep Rd; you will see that file.Rd is still open after Rdconv returns. This messed up perl script on Windows where I tried to remove the directory containing the *.R files after processing them and I could not remove it because the last file processed was still open. Making the following change to RHOME/share/perl/R/Rdconv.pm seems to fix it. 77,78c77,82 open(rdfile, $Rdname) or die Rdconv(): Couldn't open '$Rdname': $!\n; --- open(my $rdfile, $Rdname) or die Rdconv(): Couldn't open '$Rdfile': $!\n; # Before we added the 'my $' in front of rdfile, # rdfile was not getting closed. Now it will close # when $rdfile goes out of scope. (We could have added # a close rdfile at the end of the while(rdfile), but # scoping method is more reliable. 123c127 while(rdfile){ --- while($rdfile){ -Bill __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- 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-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] proposal for lower.tri and upper.tri value argument
Is there a case to be made for this? If so, where is it? (I don't find x[lower.tri(x)] harder to write than lower.tri(x, value=TRUE), and wonder why you do? For grep, one can argue that handling empty sets is clearer with value=, but I have seen quite a few uses where that is not used and could have been.) On Sat, 5 Aug 2006, Patrick Burns wrote: I propose that a 'value' argument be added to 'lower.tri' and 'upper.tri'. This is analogous to the 'value' argument of 'grep'. Something like the following should work: upper.tri function (x, diag = FALSE, value = FALSE) { x - as.matrix(x) if (diag) ans - row(x) = col(x) else ans - row(x) col(x) if(value) x[ans] else ans } environment: namespace:base -- 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-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] proposal for lower.tri and upper.tri value argument
On 8/6/06, Prof Brian Ripley [EMAIL PROTECTED] wrote: Is there a case to be made for this? If so, where is it? (I don't find x[lower.tri(x)] harder to write than lower.tri(x, value=TRUE), and wonder why you do? The reasons are 1. x might be the result of an expression. Without value= one must store the result of that expression in a variable, x, first: x - outer(1:6, 1:6, +) x[lower.tri(x)] but with the proposed value= argument one could just use function composition: lower.tri(outer(1:6, 1:6, +), value = TRUE) 2. the whole object approach of R encourages working with the objects themselves rather than indexes and value= is consistent with that. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] proposal for lower.tri and upper.tri value argument
Gabor came close to the situation I had yesterday that prompted me to write a local version of 'lower.tri'. It was approximately: x[sub, sub][lower.tri(x[sub,sub])] Pat Gabor Grothendieck wrote: On 8/6/06, Prof Brian Ripley [EMAIL PROTECTED] wrote: Is there a case to be made for this? If so, where is it? (I don't find x[lower.tri(x)] harder to write than lower.tri(x, value=TRUE), and wonder why you do? The reasons are 1. x might be the result of an expression. Without value= one must store the result of that expression in a variable, x, first: x - outer(1:6, 1:6, +) x[lower.tri(x)] but with the proposed value= argument one could just use function composition: lower.tri(outer(1:6, 1:6, +), value = TRUE) 2. the whole object approach of R encourages working with the objects themselves rather than indexes and value= is consistent with that. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Customized Makefiles (C++ and R)
Hi everyone, I am writing a package for R and implementing a collection of C++ scripts with it. Unfortunately, I did not write the C++ files, so I am dependent on using the supplied makefile that came with it. This works fine for compiling the program outside of R, but in trying to create the package, the .o files are created but at the end I run into this error: cp: *.so: No such file or directory ERROR: compilation failed for package 'chpoly' I think this is because the .so file is never created, but I might be wrong. Is there something I have to add to the makefile to ensure that everything works out okay? Thanks so much in advance! Selwyn-Lloyd McPherson __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Can't make sort generic in quantile (S3)
Hello all, In my package I made sort() generic as follows: sort.default - sort; sort - function(x, ...) UseMethod(sort); formals(sort.default) - c(formals(sort.default), alist(...=)) then added a sort for my S3 class sort.sqlite.vector - function(x, decreasing=FALSE, ...) { .Call(sdf_sort_variable, x, as.logical(decreasing)) } In the stats::quantile() function, sort() is still bound to the original definition. I got the following error when calling quantile: Error in sort(x, partial = unique(c(lo, hi))) : 'x' must be atomic However, when I copy quantile's def'n (say as myquantile in myquantile.R), source() it then do myquantile(x), I get the results. Thanks, M. Manese __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Can't make sort generic in quantile (S3)
Try redefining quantile.default: environment(quantile.default) - .GlobalEnv For example, if you run the following in a fresh session it should print out X showing that the newly defined sort was invoked: environment(quantile.default) - .GlobalEnv sort - function(x, ...) { cat(X\n); base::sort(x, ...) } quantile(1:100) That being said, its not really a good idea to redefine functions from the core of R. Furthermore, in this case quantile is generic and sort is not generic so you would be better off creating a method for quantile rather than sort. If you do want a generic sort then use a different name such as SORT or just define sort.whatever and have the user to run that directly. Also if the only reason you are creating a generic for sort is so that it can be used in quantile then you could do something along these lines assuming your new class is X: quantile.X - function(x, ...) { sort - function(x, ...) { cat(X\n); base::sort(x, ...) } environment(quantile.default) - environment() quantile.default(x, ...) } # test it out x - structure(1:100, class = X) quantile(x) which will cause the redefined sort to be used in quantile and is a bit safer since its effect is restricted to that. On 8/6/06, miguel manese [EMAIL PROTECTED] wrote: Hello all, In my package I made sort() generic as follows: sort.default - sort; sort - function(x, ...) UseMethod(sort); formals(sort.default) - c(formals(sort.default), alist(...=)) then added a sort for my S3 class sort.sqlite.vector - function(x, decreasing=FALSE, ...) { .Call(sdf_sort_variable, x, as.logical(decreasing)) } In the stats::quantile() function, sort() is still bound to the original definition. I got the following error when calling quantile: Error in sort(x, partial = unique(c(lo, hi))) : 'x' must be atomic However, when I copy quantile's def'n (say as myquantile in myquantile.R), source() it then do myquantile(x), I get the results. Thanks, M. Manese __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel