[Rd] bug in nlme package function predict.lmList (PR#13788)
Full_Name: Vaidotas Zemlys Version: 2.9.0 OS: Ubuntu 8.10 Submission from: (NULL) (213.197.173.50) Steps to reproduce the bug: library(nlme) data(Oxboys) qm=lmList(height~age|Subject,data=Oxboys) grid=with(Oxboys,expand.grid(age=seq(min(age),max(age),length=50),Subject=levels(Subject))) res <- predict(qm,grid,se=TRUE) Erreur dans if (pool) { : l'argument est de longueur nulle res <- predict(qm,grid,se=TRUE,pool=TRUE) Erreur dans sprintf(gettext(fmt, domain = domain), ...) : objet 'form' introuvable The result: predicting does not work, when new data is supplied. The problem is in the function predict.lmList. When argument newdata is not NULL, argument subset is set to TRUE, and following code gets executed: Start of the relevant code snippet if (!is.null(subset)) { if (any(is.na(match(subset, names(object) { stop("Non-existent group requested in \"subset\".") } oclass <- class(object) oatt <- attr(object, "call") object <- object[subset] attr(object, "call") <- oatt class(object) <- oclass if (is.null(newdata)) { myData <- myData[subset] } } #End of relevant code snippet Only attribute call is saved from original object, but the following code assumes that attributes groupsForm and pool are present, and when they are not found, error is produced. The problem with missing pool attribute can be worked arround by supplying it directly. But it is not possible to do that with attribute groupsForm. The patch which fixes this problem : --- lmList.R2008-02-11 16:05:14.0 +0200 +++ lmListnew.R 2009-06-30 09:49:21.0 +0300 @@ -853,9 +853,10 @@ predict.lmList <- stop("Non-existent group requested in \"subset\".") } oclass <- class(object) -oatt <- attr(object, "call") +oatt <- attributes(object)[c("call","groupsForm","pool")] object <- object[subset] -attr(object, "call") <- oatt +oatt <- c(attributes(object),oatt) +attributes(object) <- oatt class(object) <- oclass if(is.null(newdata)) { myData <- myData[subset] I did not do extensive tests, but it works with previous example and my own datasets. Here is the relevant information about R and nlme on my system: > R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 9.0 year 2009 month 04 day17 svn rev48333 language R version.string R version 2.9.0 (2009-04-17) > packageDescription("nlme") Package: nlme Version: 3.1-92 Date: 2009-05-22 Priority: recommended Title: Linear and Nonlinear Mixed Effects Models Author: Jose Pinheiro , Douglas Bates , Saikat DebRoy , Deepayan Sarkar , the R Core team. Maintainer: R-core Description: Fit and compare Gaussian linear and nonlinear mixed-effects models. Depends: graphics, stats, R (>= 2.4.0) Imports: lattice LazyLoad: yes LazyData: yes License: GPL (>= 2) Packaged: 2009-05-23 16:39:47 UTC; ripley Repository: CRAN Date/Publication: 2009-05-24 08:46:01 Built: R 2.9.0; i486-pc-linux-gnu; 2009-06-30 06:00:47 UTC; unix I did update.packages() before testing and reporting the bug. I hope that this is correct place to report bug on package of R. Vaidotas Zemlys __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] active bindings and ls.str
On Monday 29 June 2009, Romain Francois wrote: > I'm attaching a patch that prints this instead: > > ls.str() > > xx : > > Although a better behaviour would be to show the binding function. I can see your point, but note that active bindings are not necessarily slow, and a special treatment may not be desirable in all use cases. For instance in RKWard, we use active bindings to detect, when objects are modified. To do so, we move *al* objects from .GlobalEnv to a hidden storage environment, and place corresponding active bindings in .GlobalEnv, instead. So, in our case, we'd clearly like for active bindings to behave just like regular objects, as much as possible. Regards Thomas signature.asc Description: This is a digitally signed message part. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] active bindings and ls.str
On 06/30/2009 10:35 AM, Thomas Friedrichsmeier wrote: > On Monday 29 June 2009, Romain Francois wrote: > >> I'm attaching a patch that prints this instead: >> > ls.str() >> >> xx : >> >> Although a better behaviour would be to show the binding function. >> > > I can see your point, but note that active bindings are not necessarily slow, > and a special treatment may not be desirable in all use cases. For instance in > RKWard, we use active bindings to detect, when objects are modified. To do so, > we move *al* objects from .GlobalEnv to a hidden storage environment, and > place corresponding active bindings in .GlobalEnv, instead. So, in our case, > we'd clearly like for active bindings to behave just like regular objects, as > much as possible. > > Regards > Thomas > Hi Thomas, Not sure your trick is full-proof. What happens when the variable you copy is already an active binding ? There should be another way to track changes. It is more about seeing what the object really is than speed. I feel we don't see the actual object with the current ls.str. I would also argue the same about promises: > delayedAssign( "foobar", { Sys.sleep(5); rnorm(10) } ) > ls.str() # takes 5 seconds foobar : num [1:10] -0.288 0.827 -0.466 -0.803 -1.622 ... Maybe the promise does not have to forced at that stage. Thomas, does rkward's trick force the promise when the make your copy to the hidden environment or later ? BTW, is there a way to identify an object as a promise ? > delayedAssign( "foobar", { Sys.sleep(5); rnorm(10) } ) > typeof( foobar ) # takes 5 seconds [1] "double" Romain -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] S4 and connection slot [Sec=Unclassified]
Martin Morgan wrote: [...] ## Attempt two -- initialize setClass("Element", representation=representation(conn="file")) setMethod(initialize, "Element", function(.Object, ..., conn=file()) { callNextMethod(.Object, ..., conn=conn) }) new("Element") ## oops, connection created but not closed; gc() closes (eventually) ## but with an ugly warning ## > gc() ##used (Mb) gc trigger (Mb) max used (Mb) ## Ncells 717240 38.41166886 62.4 1073225 57.4 ## Vcells 3795 284.9 63274729 482.8 60051033 458.2 ## > gc() ##used (Mb) gc trigger (Mb) max used (Mb) ## Ncells 715906 38.31166886 62.4 1073225 57.4 ## Vcells 37335626 284.9 63274729 482.8 60051033 458.2 ## Warning messages: ## 1: closing unused connection 3 () setClass("ElementX", contains="Element") ## oops, two connections opened (!) yes, that's because of the nonsense double call to the initializer while creating a subclass. the conceptual bug in the s4 system leads to this ridiculous behaviour in your essentially correct and useful pattern. vQ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] active bindings and ls.str
Hi, On Tuesday 30 June 2009, Romain Francois wrote: > Not sure your trick is full-proof. What happens when the variable you > copy is already an active binding ? see promises, below. > There should be another way to track > changes. I'm open to suggestions. > It is more about seeing what the object really is than speed. I feel we > don't see the actual object with the current ls.str. Hm, but isn't that the point of active bindings (and promises), that they are just a transparent layer, and the "actual" object *is* the result of evaluating the object? (I'm not really qualified to answer that, but that's the way I'm thinking about these concepts). > I would also argue the same about promises: > > delayedAssign( "foobar", { Sys.sleep(5); rnorm(10) } ) > > ls.str() # takes 5 seconds > > foobar : num [1:10] -0.288 0.827 -0.466 -0.803 -1.622 ... > > Maybe the promise does not have to forced at that stage. Thomas, does > rkward's trick force the promise when the make your copy to the hidden > environment or later ? On the C level it's possible (and in fact quite easily) to copy the object "as is". That's what we do. Including any active bindings and "unseen" promises. See our function doCopyNoEval() in RKWard's rembedinternal.cpp . > BTW, is there a way to identify an object as a promise ? Once again, this is possible on the C level: TYPEOF (object) == PROMSXP // a promise PRVALUE(object) == R_UnboundValue // not yet forced but when I once looked, I did not find any R level facility for this (and my guess is that this is hidden on purpose). Regards Thomas signature.asc Description: This is a digitally signed message part. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] active bindings and ls.str
On 06/30/2009 11:41 AM, Thomas Friedrichsmeier wrote: > Hi, > > On Tuesday 30 June 2009, Romain Francois wrote: > >> Not sure your trick is full-proof. What happens when the variable you >> copy is already an active binding ? >> > > see promises, below. > >> There should be another way to track >> changes. >> > > I'm open to suggestions. > This was more of a question. I'd like to know if there is a way for objects to broadcast that they have changed. This would be very useful to for example implement an object browser in a front-end, which I guess is part of the reason for the trick ? >> It is more about seeing what the object really is than speed. I feel we >> don't see the actual object with the current ls.str. >> > > Hm, but isn't that the point of active bindings (and promises), that they are > just a transparent layer, and the "actual" object *is* the result of > evaluating the object? (I'm not really qualified to answer that, but that's > the > way I'm thinking about these concepts). > >> I would also argue the same about promises: >> > delayedAssign( "foobar", { Sys.sleep(5); rnorm(10) } ) >> > ls.str() # takes 5 seconds >> >> foobar : num [1:10] -0.288 0.827 -0.466 -0.803 -1.622 ... >> >> Maybe the promise does not have to forced at that stage. Thomas, does >> rkward's trick force the promise when the make your copy to the hidden >> environment or later ? >> > > On the C level it's possible (and in fact quite easily) to copy the object "as > is". That's what we do. Including any active bindings and "unseen" promises. > See our function doCopyNoEval() in RKWard's rembedinternal.cpp . > > >> BTW, is there a way to identify an object as a promise ? >> > > Once again, this is possible on the C level: > TYPEOF (object) == PROMSXP // a promise > PRVALUE(object) == R_UnboundValue // not yet forced > but when I once looked, I did not find any R level facility for this (and my > guess is that this is hidden on purpose). > The problem is as soon as you pass it to a function, you force the promise, maybe passing the symbol instead could do the trick, but I have not seen something that brings the information that an object is a promise. Maybe you are right and I am not supposed to play with them ... > Regards > Thomas > -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] progress bar
Hello, Would it be useful to rework txtProgressBar so that front-end can pick it up and propose an alternative display. This could be done for example as a callback, as an option (similar to "pager" for example), or maybe handling a condition (if there was a way to handle conditions from the top-level). Romain -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] active bindings and ls.str
On Tuesday 30 June 2009, Romain Francois wrote: > This was more of a question. I'd like to know if there is a way for > objects to broadcast that they have changed. > This would be very useful to for example implement an object browser in > a front-end, which I guess is part of the reason for the trick ? Yes, that's around half the reason. The other half is our data.frame-editor, which tries to create the illusion of "in-place" editing. For that it's pretty important to keep the editor data in sync with R's version of the data.frame. I would certainly like to see an easier way to detect changed objects as well. > The problem is as soon as you pass it to a function, you force the > promise, maybe passing the symbol instead could do the trick, but I have > not seen something that brings the information that an object is a > promise. Maybe you are right and I am not supposed to play with them ... Yes, passing the symbol does the trick, indeed. (And until a few minutes ago, there was a regression in RKWard in just that respect.) I'll have to admit that we do play with the internals of promises in RKWard, too: When the only reason that we forced a promise was that the object browser stepped on it, we "put it back" to free up the memory, again. This works remarkably well, but in fact I don't think we are supposed to do this... Regards Thomas signature.asc Description: This is a digitally signed message part. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Conditional dependency between packages
Hi, I have already asked a similar question twice without response on the r-help list https://stat.ethz.ch/pipermail/r-help/2009-June/200300.html but this list might be more appropriate. If there is a particular reason for the lacking answers (unclear, missing information, the solution is obvious to everyone except me, etc), I would like to know. The description below is generalized, but I can send the source code off-list if anyone would like to test. I work on two packages, pkg1 and pkg2 (in two different projects). pkg1 is quite generic, pkg2 tries to solve a particular problem within same field (geostatistics). Therefore, there might be users who want to use pkg2 as an add-on package to increase the functionality of pkg1. In other words, functions in pkg1 are based on the S3 class system, and I want pkg2 to offer methods for pkg2-objects to functions defined in pkg1, for users having both packages installed. Merging the packages or making pkg2 always depend pkg1 would be the easiest solution, but it is not preferred as most users will only be interested in one of the packages. I thought this could be solved by including the following in NAMESPACE of pkg2: if ("pkg1" %in% rownames(utils:::installed.packages()) { importFrom(pkg1, fun1, fun2, fun3) S3method(fun1, class2) S3method(fun2, class2) S3method(fun3, class2) } Unfortunately, this doesn't seem to work as I expected, particularly when I try to build a binary for Windows-users (R CMD build -binary pkg2 or R CMD INSTALL --build pkg2). It seems for me that the dependency between pkg2 and pkg1 is defined at the time of building a binary, not when the package is loaded with library(pkg2): If I have pkg1 installed when I build pkg2, the package will not load for users who do not have pkg1 installed: > install.packages("d:/pkg2_0.1-1.zip", repos=NULL) > library(pkg2) (...) Error : object 'fun1' not found whilst loading namespace 'pkg2' Error: package/namespace load failed for 'pkg2' If I remove pkg1 from the library before building pkg2, pkg2 can be installed and loaded by everyone, but the new method is not visible for those with pkg1 installed: > install.packages("d:/pkg2_0.1-2.zip", repos=NULL) > library(pkg1) > library(pkg2) > methods(fun1) [1] fun1.class1* Non-visible functions are asterisked I have tried with and without one of the following: Suggests: pkg1 Enhances: pkg1 in the DESCRIPTION file of pkg2, but I cannot see that either of them make a difference. I can of course solve this problem temporarily, building two different versions of pkg2, with and without pkg1 installed on my computer. But first of all, that seems unnecessary complicated, and more important, the plan is also to upload these packages to CRAN where I doubt that such a two-version solution is possible or accepted. Is there a way to build one binary that works both with and without having pkg1 installed? I have tried to search in mail archives and "Writing R extensions", but either it is not there, or I have missed it. Thanks, Jon BTW, I am using R version 2.9.1 and Rtools version 29 under Windows XP-SP3 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Matrix with random number
Hello! I have a program in Fortran and would like to build a matrix with random numbers, I have a function in C. However, I have problems with the use of function in R. Code to compile: R CMD SHLIB mat.f myrbeta.c -o func.so Code in C. #include #include void F77_SUB(fseedi)(void){ GetRNGstate(); } void F77_SUB(fseedo)(void){ PutRNGstate(); } void F77_SUB(myrbeta)(double *px, double *pa, double *pb){ *px = rbeta(*pa,*pb); } Code in Fortran subroutine mat(x,l,c) integer l,c double precision x(l,c) integer i,j do j = 1, c do i = 1, l call fseedi() x(i,j) = call myrbeta(1,4,5) ! It's correct? call fseedo() enddo enddo end Thanks very much! -- Fábio Mathias Corrêa Estatística e Experimentação Agropecuária Fábio Mathias Corrêa UFLA [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Matrix with random number
Hello! I have a program in Fortran and would like to build a matrix with random numbers, I have a function in C. However, I have problems with the use of function in R. Code to compile: R CMD SHLIB mat.f myrbeta.c -o func.so Code in C. #include #include void F77_SUB(fseedi)(void){ GetRNGstate(); } void F77_SUB(fseedo)(void){ PutRNGstate(); } void F77_SUB(myrbeta)(double *px, double *pa, double *pb){ *px = rbeta(*pa,*pb); } Code in Fortran subroutine mat(x,l,c) integer l,c double precision x(l,c) integer i,j do j = 1, c do i = 1, l call fseedi() x(i,j) = call myrbeta(1,4,5) ! It's correct? call fseedo() enddo enddo end The code of the error in R is: dyn.load("func.so") Error in dyn.load("func.so") : unable to load shared library '/home/julio/Orientados/Fabio/Fortran/mat-fortran/func.so': /home/julio/Orientados/Fabio/Fortran/mat-fortran/func.so: undefined symbol: callmyrbeta_ Thanks very much! Fábio Mathias Corrêa UFLA [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] install.packages with R 2.9.1 under Vista?
What do I need to do to get "install.packages" to work properly for me in R 2.9.1 under Vista? Currently, install.packages in Rgui 2.9.1 by default goes to "C:\\Users\\sgraves\\Documents/R/win-library/2.9". This is a problem for me, because R running under Emacs does not currently look there. I made the mistake last night of first installing R 2.9.1 in the default "C:\Program Files". When I found that packages I installed using Rgui could not be found from within Emacs, I uninstalled R from "C:\Program Files" and reinstalled it under "C:\Users\sgraves\R" alongside R 2.9.0, which has allowed "install.packages" from Rgui to be accessed from R under Emacs. I've traced the problem to the different behavior of ".libPaths()": *** Rgui: .libPaths() [1] "C:\\Users\\sgraves\\Documents/R/win-library/2.9" [2] "C:/Users/sgraves/R/R-2.9.1/library" *** R under Emacs: > .libPaths() [1] "c:/Users/sgraves/R/R-2.9.1/library" What do you suggest? Thanks, Spencer __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Matrix with random number
> x(i,j) = call myrbeta(1,4,5) ! It's correct? > The code of the error in R is: > dyn.load("func.so") > Error in dyn.load("func.so") : > unable to load shared library > '/home/julio/Orientados/Fabio/Fortran/mat-fortran/func.so': > /home/julio/Orientados/Fabio/Fortran/mat-fortran/func.so: undefined symbol: > callmyrbeta_ Fortran doesn't use 'CALL' when calling a function. Try: x(i,j) = myrbeta(1,4,5) Fortran has SUBROUTINEs (which are CALLed and don't return a value) and FUNCTIONs - which are just used like any other function. Barry __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] active bindings and ls.str
Thomas Friedrichsmeier wrote: On Tuesday 30 June 2009, Romain Francois wrote: This was more of a question. I'd like to know if there is a way for objects to broadcast that they have changed. This would be very useful to for example implement an object browser in a front-end, which I guess is part of the reason for the trick ? Yes, that's around half the reason. The other half is our data.frame-editor, which tries to create the illusion of "in-place" editing. For that it's pretty important to keep the editor data in sync with R's version of the data.frame. I would certainly like to see an easier way to detect changed objects as well. I used active bindings for the same purpose (tracking changes to objects) in the package trackObjs. Prior to using active bindings, I experimented with changes in the C code that added hooks to an environment so that an R function could be called when an object in the environment was created, changed or deleted. This code was reasonably simple, and I'd be happy to share it if there is any interest (it was for R-2.4.1). -- Tony Plate The problem is as soon as you pass it to a function, you force the promise, maybe passing the symbol instead could do the trick, but I have not seen something that brings the information that an object is a promise. Maybe you are right and I am not supposed to play with them ... Yes, passing the symbol does the trick, indeed. (And until a few minutes ago, there was a regression in RKWard in just that respect.) I'll have to admit that we do play with the internals of promises in RKWard, too: When the only reason that we forced a promise was that the object browser stepped on it, we "put it back" to free up the memory, again. This works remarkably well, but in fact I don't think we are supposed to do this... Regards Thomas __ 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
Re: [Rd] Matrix with random number
Thanks Mr. Barry Rowlingson However, the matrix appears to zeros! Notice the code below! Please! Code in fortran subroutine mat(x,l,c,a) integer l,c double precision x(l,c), a integer i,j do j = 1, c do i = 1, l call fseedi() x(i,j) = myrbeta(a,1,2) call fseedo() enddo enddo end In R: dyn.load("func.so") x <- matrix(0,5,6) l <- nrow(x) c <- ncol(x) a <- 0 ..Fortran("mat", x = x, l, c, as.double(a)) Results: $x [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 [3,] 0 0 0 0 0 0 [4,] 0 0 0 0 0 0 [5,] 0 0 0 0 0 0 [[2]] [1] 5 [[3]] [1] 6 [[4]] [1] 1 Thanks!!! Fábio Mathias Corrêa UFLA [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] S4 class redefinition
I haven't found much on S4 class redefinition; the little I've seen indicates the following is to be expected: 1. setClass("foo", ) 2. create objects of class foo. 3. execute the same setClass("foo", ...) again (source the same file). 4. objects from step 2 are now NULL. Is that the expected behavior (I ran under R 2.7.1)? Assuming it is, it's kind of unfortunate. I can wrap my setClass code like this if (! isClass("foo")) setClass("foo", ) to avoid this problem. I've seen this in other code; is that the standard solution? I thought that loading a library was about the same as executing the code in its source files (assuming R only code). But if this were true my saved objects would be nulled out each time I loaded the corresponding library. That does not seem to be the case. Can anyone explain that? Do I need to put any protections around setMethod so that it doesn't run if the method is already defined? At the moment I'm not changing the class defintion but am changing the methods, so I can simply avoid running setClass. But if I want to change the class, most likely by adding a slot, what do I do? At the moment it looks as if I'd need to make a new class name, define some coerce methods, and then locate and change the relevant instances. Is there a better way? Thanks. Ross Boylan __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] S4 class redefinition
On Tue, 2009-06-30 at 12:58 -0700, Ross Boylan wrote: > I haven't found much on S4 class redefinition; the little I've seen > indicates the following is to be expected: > 1. setClass("foo", ) > 2. create objects of class foo. > 3. execute the same setClass("foo", ...) again (source the same file). > 4. objects from step 2 are now NULL. I'm sorry; step 4 is completely wrong. The objects seem to be preserved. Some slightly modified questions remain. Is it safe to reexecute identical code for setClass or setMethod when you have existing objects of the class around? Is there any protection, such as checking for existing definitions, that is recommended before executing setClass or setMethod? If you want to change a class or method, and have existing objects, how do you do that? Can scoping rules lead to situations in which some functions or methods end up with references to the older version of the methods? One example is relevant to class constructors, and shows they can: Here's a little test > trivial <- function() 3 # stand in for a class constructor > maker <- function(c=trivial) + function(x) x+c() > oldf <- maker() > oldf(4) [1] 7 > trivial <- function() 20 > oldf(4) [1] 7 > newf <- maker() > newf(8) [1] 28 So the old definition is frozen in the inner function, for which it was captured by lexical scope. Although definition of maker is not redone after trivial is redefined, maker's default argument does get the new value of trivial. Methods add another layer. I'm hoping those with a deeper understanding than mine can clarify where the danger spots are, and how to deal with them. Thanks. Ross > > Is that the expected behavior (I ran under R 2.7.1)? > > Assuming it is, it's kind of unfortunate. I can wrap my setClass code > like this > if (! isClass("foo")) setClass("foo", ) > to avoid this problem. I've seen this in other code; is that the > standard solution? > > I thought that loading a library was about the same as executing the > code in its source files (assuming R only code). But if this were true > my saved objects would be nulled out each time I loaded the > corresponding library. That does not seem to be the case. Can anyone > explain that? > > Do I need to put any protections around setMethod so that it doesn't run > if the method is already defined? > > At the moment I'm not changing the class defintion but am changing the > methods, so I can simply avoid running setClass. > > But if I want to change the class, most likely by adding a slot, what do > I do? At the moment it looks as if I'd need to make a new class name, > define some coerce methods, and then locate and change the relevant > instances. Is there a better way? > > Thanks. > Ross Boylan > > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] install.packages with R 2.9.1 under Vista?
spencerg wrote: What do I need to do to get "install.packages" to work properly for me in R 2.9.1 under Vista? Currently, install.packages in Rgui 2.9.1 by default goes to "C:\\Users\\sgraves\\Documents/R/win-library/2.9". This is a problem for me, because R running under Emacs does not currently look there. I made the mistake last night of first installing R 2.9.1 in the default "C:\Program Files". When I found that packages I installed using Rgui could not be found from within Emacs, I uninstalled R from "C:\Program Files" and reinstalled it under "C:\Users\sgraves\R" alongside R 2.9.0, which has allowed "install.packages" from Rgui to be accessed from R under Emacs. I've traced the problem to the different behavior of ".libPaths()": *** Rgui: .libPaths() [1] "C:\\Users\\sgraves\\Documents/R/win-library/2.9" [2] "C:/Users/sgraves/R/R-2.9.1/library" *** R under Emacs: > .libPaths() [1] "c:/Users/sgraves/R/R-2.9.1/library" What do you suggest? Thanks, Either set for the second setup "C:\\Users\\sgraves\\Documents/R/win-library/2.9" as a default library path (e.g. via env var R_LIBS) or remove it from the first setup (in a personal startup file). Best wishes, Uwe Spencer __ 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
Re: [Rd] install.packages with R 2.9.1 under Vista?
Dear Uwe: Thanks very much. Based on your suggestion, I deleted "C:\\Users\\sgraves\\Documents/R/win-library/2.9", which got created when I first installed R 2.9.1 into the default, write-protected area and then did "install.packages". When I uninstalled that write-protected copy and installed it in a different location, the directory "C:\\Users\\sgraves\\Documents/R/win-library/2.9" remained, and Rgui directed "install.packages" to that directory, though Rterm did not. I had not intentionally set "R_LIBS" nor any other special thing like that, so I was confused. Thanks again. Best Wishes, Spencer Uwe Ligges wrote: spencerg wrote: What do I need to do to get "install.packages" to work properly for me in R 2.9.1 under Vista? Currently, install.packages in Rgui 2.9.1 by default goes to "C:\\Users\\sgraves\\Documents/R/win-library/2.9". This is a problem for me, because R running under Emacs does not currently look there. I made the mistake last night of first installing R 2.9.1 in the default "C:\Program Files". When I found that packages I installed using Rgui could not be found from within Emacs, I uninstalled R from "C:\Program Files" and reinstalled it under "C:\Users\sgraves\R" alongside R 2.9.0, which has allowed "install.packages" from Rgui to be accessed from R under Emacs. I've traced the problem to the different behavior of ".libPaths()": *** Rgui: .libPaths() [1] "C:\\Users\\sgraves\\Documents/R/win-library/2.9" [2] "C:/Users/sgraves/R/R-2.9.1/library" *** R under Emacs: > .libPaths() [1] "c:/Users/sgraves/R/R-2.9.1/library" What do you suggest? Thanks, Either set for the second setup "C:\\Users\\sgraves\\Documents/R/win-library/2.9" as a default library path (e.g. via env var R_LIBS) or remove it from the first setup (in a personal startup file). Best wishes, Uwe Spencer __ 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