Re: [Rd] Significant memory leak when using XML on Windows
@Jeroen: nope, seems like the problem unfortunately persists: require("XML") getTaskMemoryByPid <- function( pid = Sys.getpid() ) { cmd <- sprintf("tasklist /FI \"pid eq %s\" /FO csv", pid) mem <- read.csv(text=shell(cmd, intern = TRUE), stringsAsFactors=FALSE)[,5] mem <- as.numeric(gsub("\\.|\\s|K", "", mem))/1000 mem } getCurrentMemoryStatus <- function() { mem_os <- getTaskMemoryByPid() mem_r <- memory.size() prof_1 <- memory.profile() list(r = mem_r, os = mem_os, ratio = mem_os/mem_r) } memoryLeak <- function( x = system.file("exampleData", "mtcars.xml", package="XML"), n = 5000, free_doc = FALSE, rm_doc = FALSE, use_gc = FALSE ) { lapply(1:n, function(ii) { doc <- xmlParse(x) if (free_doc) free(doc) if (rm_doc) rm(doc) if (use_gc) gc() NULL }) } mem_1 <- getCurrentMemoryStatus() memoryLeak(n = 5, free_doc = TRUE, rm_doc = TRUE) mem_2 <- getCurrentMemoryStatus() > rbind(data.frame(mem_1), data.frame(mem_2)) r osratio 1 63.65 87.148 1.369175 2 97.63 122.160 1.251255 On Mon, Dec 15, 2014 at 12:25 PM, Janko Thyson wrote: > > Sorry guys, didn't see your responses before sending mine. > > Thanks jeroen!! I'll test your version today and get back to you. > > Gesendet von meinem Smartphone > Am 15.12.2014 12:12 schrieb "Janko Thyson" : > > > Thanks a lot for answering. Before I get into it, please note that > > everything below bears the big capture "Thanks for trying to help me at > > all". > > > > 1) Yeah, those examples - quite hard to satisfy everyone's needs ;-) > While > > the one side complained that my past examples regarding this issue were > not > > informative enough, others didn't like the more elaborated version (as > > seems to be the case for you). I simply tried to make it as easy as > > possible for people to see what's actually going on so they wouldn't have > > to program their own stuff for things like reading the actual memory > > consumed by the Rterm process etc.. If you prefer plain vanilla, though, > I > > guess this would be it: > > > > memoryLeak <- function( > > x = system.file("exampleData", "mtcars.xml", package="XML"), > > n = 5000, > > free_doc = FALSE, > > rm_doc = FALSE, > > use_gc = FALSE > > ) { > > lapply(1:n, function(ii) { > > doc <- xmlParse(x) > > if (free_doc) free(doc) > > if (rm_doc) rm(doc) > > if (use_gc) gc() > > NULL > > }) > > } > > > > 2) If I knew my way around OSX or Linux, I would be happy to go with your > > suggestions - but as I'm not, unfortunately that's out of reach for me. > But > > IMO, a deeper level of cross-platform expertise should **not** be a > > generall prerequisite before you can ask for help - even at r-devel (as > > opposed to r-help). However, AFAIK from past conversations with Duncan, > the > > problem is indeed Windows-specific as on all his non-Windows > infrastructure > > (definitely Linux, possibly OSX), everything went fine. > > > > 3) The same goes for the level of expertise in C. After all, R is not C. > I > > totally agree that the more programming languages one knows, the better. > > But again: I don't think that knowing your way around C should be a > > prerequisite for asking for help when an *R function* interfacing C > causes > > trouble. Requesting this would sort of oppose R's nature/paradigm of > being > > an awesome "top-level" interfacing language. But I'll try to narrow the > > problem down on a C-level if I can help you with that. > > > > 4) Both Duncan as well as Hadley have suggested that libxml2 is indeed > > causing the problem. So trying to link against another build would > possibly > > be a great way to start! How would I go about that? > > > > Thanks if you should take the time to further look into this! > > Janko > > > > On Mon, Dec 15, 2014 at 4:54 AM, Jeroen Ooms > wrote: > >> > >> On Thu, Dec 11, 2014 at 12:13 PM, Janko Thyson > >> wrote: > >>> > >>> I'd so much appreciate if someone could have a look at this. If I can > be > >>> of > >>> any help whatsoever, please let me know! > >>> > >> > >> Your current code uses various functions from XML and rvest so it is not > >> a *minimal* reproducible example. Even if you are unfamiliar with C, you > >> shou
Re: [Rd] Significant memory leak when using XML on Windows
Sorry guys, didn't see your responses before sending mine. Thanks jeroen!! I'll test your version today and get back to you. Gesendet von meinem Smartphone Am 15.12.2014 12:12 schrieb "Janko Thyson" : > Thanks a lot for answering. Before I get into it, please note that > everything below bears the big capture "Thanks for trying to help me at > all". > > 1) Yeah, those examples - quite hard to satisfy everyone's needs ;-) While > the one side complained that my past examples regarding this issue were not > informative enough, others didn't like the more elaborated version (as > seems to be the case for you). I simply tried to make it as easy as > possible for people to see what's actually going on so they wouldn't have > to program their own stuff for things like reading the actual memory > consumed by the Rterm process etc.. If you prefer plain vanilla, though, I > guess this would be it: > > memoryLeak <- function( > x = system.file("exampleData", "mtcars.xml", package="XML"), > n = 5000, > free_doc = FALSE, > rm_doc = FALSE, > use_gc = FALSE > ) { > lapply(1:n, function(ii) { > doc <- xmlParse(x) > if (free_doc) free(doc) > if (rm_doc) rm(doc) > if (use_gc) gc() > NULL > }) > } > > 2) If I knew my way around OSX or Linux, I would be happy to go with your > suggestions - but as I'm not, unfortunately that's out of reach for me. But > IMO, a deeper level of cross-platform expertise should **not** be a > generall prerequisite before you can ask for help - even at r-devel (as > opposed to r-help). However, AFAIK from past conversations with Duncan, the > problem is indeed Windows-specific as on all his non-Windows infrastructure > (definitely Linux, possibly OSX), everything went fine. > > 3) The same goes for the level of expertise in C. After all, R is not C. I > totally agree that the more programming languages one knows, the better. > But again: I don't think that knowing your way around C should be a > prerequisite for asking for help when an *R function* interfacing C causes > trouble. Requesting this would sort of oppose R's nature/paradigm of being > an awesome "top-level" interfacing language. But I'll try to narrow the > problem down on a C-level if I can help you with that. > > 4) Both Duncan as well as Hadley have suggested that libxml2 is indeed > causing the problem. So trying to link against another build would possibly > be a great way to start! How would I go about that? > > Thanks if you should take the time to further look into this! > Janko > > On Mon, Dec 15, 2014 at 4:54 AM, Jeroen Ooms wrote: >> >> On Thu, Dec 11, 2014 at 12:13 PM, Janko Thyson >> wrote: >>> >>> I'd so much appreciate if someone could have a look at this. If I can be >>> of >>> any help whatsoever, please let me know! >>> >> >> Your current code uses various functions from XML and rvest so it is not >> a *minimal* reproducible example. Even if you are unfamiliar with C, you >> should be able to investigate exactly which function in the XML package you >> think has issues. Once you found the problematic R function, inspect the >> source code or use debug() to see if you can narrow it down even further, >> preferably to a particular call to C. >> >> Moreover you should create a reproducible example that allows us (and >> you) to test if this problem appears on other systems such as OSX or linux. >> Development and debugging on Windows is very painful so your windows-only >> example is not too helpful. Making people use windows is not a good >> strategy for getting help. >> >> If the "leak" does not appear on other systems, it is likely a problem in >> the libxml2 windows library on cran. In that case we can try to link >> against another build. On the other hand, if the problem does appear across >> systems, and you have provided a minimal reproducible example that >> pinpoints the problematic C function, we can help you review/debug the code >> C to see if/where some allocated object is not properly freed. >> >> >> >> [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Significant memory leak when using XML on Windows
Sorry guys, didn't see your responses before sending mine. Thanks jeroen!! I'll test your version today and get back to you. Gesendet von meinem Smartphone Am 15.12.2014 12:12 schrieb "Janko Thyson" : > Thanks a lot for answering. Before I get into it, please note that > everything below bears the big capture "Thanks for trying to help me at > all". > > 1) Yeah, those examples - quite hard to satisfy everyone's needs ;-) While > the one side complained that my past examples regarding this issue were not > informative enough, others didn't like the more elaborated version (as > seems to be the case for you). I simply tried to make it as easy as > possible for people to see what's actually going on so they wouldn't have > to program their own stuff for things like reading the actual memory > consumed by the Rterm process etc.. If you prefer plain vanilla, though, I > guess this would be it: > > memoryLeak <- function( > x = system.file("exampleData", "mtcars.xml", package="XML"), > n = 5000, > free_doc = FALSE, > rm_doc = FALSE, > use_gc = FALSE > ) { > lapply(1:n, function(ii) { > doc <- xmlParse(x) > if (free_doc) free(doc) > if (rm_doc) rm(doc) > if (use_gc) gc() > NULL > }) > } > > 2) If I knew my way around OSX or Linux, I would be happy to go with your > suggestions - but as I'm not, unfortunately that's out of reach for me. But > IMO, a deeper level of cross-platform expertise should **not** be a > generall prerequisite before you can ask for help - even at r-devel (as > opposed to r-help). However, AFAIK from past conversations with Duncan, the > problem is indeed Windows-specific as on all his non-Windows infrastructure > (definitely Linux, possibly OSX), everything went fine. > > 3) The same goes for the level of expertise in C. After all, R is not C. I > totally agree that the more programming languages one knows, the better. > But again: I don't think that knowing your way around C should be a > prerequisite for asking for help when an *R function* interfacing C causes > trouble. Requesting this would sort of oppose R's nature/paradigm of being > an awesome "top-level" interfacing language. But I'll try to narrow the > problem down on a C-level if I can help you with that. > > 4) Both Duncan as well as Hadley have suggested that libxml2 is indeed > causing the problem. So trying to link against another build would possibly > be a great way to start! How would I go about that? > > Thanks if you should take the time to further look into this! > Janko > > On Mon, Dec 15, 2014 at 4:54 AM, Jeroen Ooms wrote: >> >> On Thu, Dec 11, 2014 at 12:13 PM, Janko Thyson >> wrote: >>> >>> I'd so much appreciate if someone could have a look at this. If I can be >>> of >>> any help whatsoever, please let me know! >>> >> >> Your current code uses various functions from XML and rvest so it is not >> a *minimal* reproducible example. Even if you are unfamiliar with C, you >> should be able to investigate exactly which function in the XML package you >> think has issues. Once you found the problematic R function, inspect the >> source code or use debug() to see if you can narrow it down even further, >> preferably to a particular call to C. >> >> Moreover you should create a reproducible example that allows us (and >> you) to test if this problem appears on other systems such as OSX or linux. >> Development and debugging on Windows is very painful so your windows-only >> example is not too helpful. Making people use windows is not a good >> strategy for getting help. >> >> If the "leak" does not appear on other systems, it is likely a problem in >> the libxml2 windows library on cran. In that case we can try to link >> against another build. On the other hand, if the problem does appear across >> systems, and you have provided a minimal reproducible example that >> pinpoints the problematic C function, we can help you review/debug the code >> C to see if/where some allocated object is not properly freed. >> >> >> >> [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Significant memory leak when using XML on Windows
Thanks a lot for answering. Before I get into it, please note that everything below bears the big capture "Thanks for trying to help me at all". 1) Yeah, those examples - quite hard to satisfy everyone's needs ;-) While the one side complained that my past examples regarding this issue were not informative enough, others didn't like the more elaborated version (as seems to be the case for you). I simply tried to make it as easy as possible for people to see what's actually going on so they wouldn't have to program their own stuff for things like reading the actual memory consumed by the Rterm process etc.. If you prefer plain vanilla, though, I guess this would be it: memoryLeak <- function( x = system.file("exampleData", "mtcars.xml", package="XML"), n = 5000, free_doc = FALSE, rm_doc = FALSE, use_gc = FALSE ) { lapply(1:n, function(ii) { doc <- xmlParse(x) if (free_doc) free(doc) if (rm_doc) rm(doc) if (use_gc) gc() NULL }) } 2) If I knew my way around OSX or Linux, I would be happy to go with your suggestions - but as I'm not, unfortunately that's out of reach for me. But IMO, a deeper level of cross-platform expertise should **not** be a generall prerequisite before you can ask for help - even at r-devel (as opposed to r-help). However, AFAIK from past conversations with Duncan, the problem is indeed Windows-specific as on all his non-Windows infrastructure (definitely Linux, possibly OSX), everything went fine. 3) The same goes for the level of expertise in C. After all, R is not C. I totally agree that the more programming languages one knows, the better. But again: I don't think that knowing your way around C should be a prerequisite for asking for help when an *R function* interfacing C causes trouble. Requesting this would sort of oppose R's nature/paradigm of being an awesome "top-level" interfacing language. But I'll try to narrow the problem down on a C-level if I can help you with that. 4) Both Duncan as well as Hadley have suggested that libxml2 is indeed causing the problem. So trying to link against another build would possibly be a great way to start! How would I go about that? Thanks if you should take the time to further look into this! Janko On Mon, Dec 15, 2014 at 4:54 AM, Jeroen Ooms wrote: > > On Thu, Dec 11, 2014 at 12:13 PM, Janko Thyson > wrote: >> >> I'd so much appreciate if someone could have a look at this. If I can be >> of >> any help whatsoever, please let me know! >> > > Your current code uses various functions from XML and rvest so it is not a > *minimal* reproducible example. Even if you are unfamiliar with C, you > should be able to investigate exactly which function in the XML package you > think has issues. Once you found the problematic R function, inspect the > source code or use debug() to see if you can narrow it down even further, > preferably to a particular call to C. > > Moreover you should create a reproducible example that allows us (and you) > to test if this problem appears on other systems such as OSX or linux. > Development and debugging on Windows is very painful so your windows-only > example is not too helpful. Making people use windows is not a good > strategy for getting help. > > If the "leak" does not appear on other systems, it is likely a problem in > the libxml2 windows library on cran. In that case we can try to link > against another build. On the other hand, if the problem does appear across > systems, and you have provided a minimal reproducible example that > pinpoints the problematic C function, we can help you review/debug the code > C to see if/where some allocated object is not properly freed. > > > > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Significant memory leak when using XML on Windows
Dear list, I'm sorry to keep coming back with this time and time again, but this bug is still not fixed even though the root cause of the issue has been around for 2-3 years now. And as the number of packages that depend on XML grows, I thought maybe this deserves some wider attention. I did my best to make reproduction of the issue as easy as possible: https://github.com/omegahat/XML/issues/4 http://goo.gl/aV17Lv But as I'm not familiar with C I'm kind of out of clues of what else do to. Duncan has been really dedicated and helpful so far, but unfortunately he seems to have too little time to really dig into this himself. So I thought I'd try and raise the attention of other developers that have the skills to fix this. Apparently, the issue is caused by the way the memory consumed by the underlying C-objects/pointers is released (or not released, for that matter). I'd so much appreciate if someone could have a look at this. If I can be of any help whatsoever, please let me know! Thanks and best regards, Janko [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Feature request: mixing `...` (three dots) with other formal arguments in S4 methods
Well, the benefit lies in the ability to pass along arguments via `...` to more than one recipient that use *identical argument names* and/or when these recipients are not necessarily located on the same calling stack layer. I'm *not* after a *general* change in the way arguments are dispatched/functions are called as I'm actually a big friend of keepings things quite explicit (thus declaring explicitly what's passed on to subsequent functions by defining respective formal arguments). Nevertheless, sometimes it's quite handy to use `...`. Consider the implementation of `plot()`. It uses `...` quite extensively to pass things along to `par()` which makes perfect sense: declaring formal arguments for things that are merely passed along to `par()` in *all* functions that depend on `par()` would probably be a developer's nightmare w.r.t. refactoring should `par()` ever change. But let's say that at one point in time, developers decide that `par()` can also call something like `parShiny()` if `shiny = TRUE` in order encapsulate shiny-specific graphical parameters in a own function (sorry, I couldn't come up with a better example just now). I'm using a simplified example where `cex` is indeed a formal parameter (which is not the case in the actual `par()`): myPlot <- function(x, ...) { myPar(...) } myPar <- function (cex = 1.0, shiny = FALSE, ...) { if (!shiny) { message("myPar/cex:") print(cex) } else { parShiny(...) } } parShiny <- function (cex = 1.0) { message("parShiny/cex:") print(cex) } > myPlot(x = 10, cex = 1.25) myPar/cex: [1] 1.25 > myPlot(x = 10, cex = 1.25, shiny = TRUE) parShiny/cex: [1] 1 So: due to the fact that `myPar()` has a formal argument `cex`, `...` is out of the question for passing along `cex` to `parShiny()`. You'd have to change things to `parShiny(cex = cex)` in the implementation of `myPar()` in order for this to work as expected - which you might or might not feel is (too) cumbersome. While it probably makes a lot of sense to pass things along explicitly in 95 % of cases, there might be situations where you'd prefer to being able to use `...`. But I don't want to overstress the (current) purpose/use case behind my request. I just wondered if the limitation of not being able to mix `...` with other formal arguments could be lifted soon as the possiblity is already stated at `?dotsMethods` :-) On Fri, Nov 28, 2014 at 2:40 AM, Gabriel Becker wrote: > I think I understand what you're saying now, but I'm still kind of missing > the benefit from the approach. > > As far as I can tell just giving foo formals for the arguments you want it > to catch gives you the end result you want, doesn't it? > > And if the generic has ... in it, you can (if you're very careful) add > formals to specific methods that would capture arguments not meant for > other methods of the same generic. > > ~G > > On Thu, Nov 27, 2014 at 11:26 AM, Janko Thyson > wrote: > >> Hi Gabriel, >> >> and thanks for answering. I'm basically just trying to find a way to use >> the power of `...` in more complex scenarios and I'm well aware that this >> might not be the best approach ;-) >> >> Regarding your actual question: >> "Are you suggesting methods be dispatched based on the *contents* of ... >> [...]?" >> Yes, I guess currently I kind of do - but not on the argument *names* >> >> I'm not expecting functions to detect the argument *names* from `...`, >> but the relevant "argument containers" from which then the actual arguments >> should be extracted and used: >> >> I thought the *actual* arguments to be passed via `...` to subsequent >> functions/methods could be put into an "arguments container" (as a list so >> you could easily use them with `do.call(foo)`) that has a class that `foo` >> expects for its `...` argument (e.g. `ThreedotsForFoo`). What I would like >> to accomplish is that `foo` auto-detects those parts coming in via `...` >> that are *relevant* for itself (e.g. instances of the argument container >> `ThreedotsForFoo`), that it handles them in a proper way (i.e. extracting >> the *actual* arguments from the container) and that it passes `...` along >> to subsequently called functions. >> >> That's why I would need methods that use mix of regular formal arguments >> and `...`. >> >> Best regards, >> Janko >> >> >> On Thu, Nov 27, 2014 at 7:48 PM, Gabriel Becker >> wrote: >> >>> Janko, >>> >>> I'm not entirely sure I understand your proposal. Are you suggesting >>> methods be dispatched based on the *contents* of ... (i
Re: [Rd] Feature request: mixing `...` (three dots) with other formal arguments in S4 methods
Hi Gabriel, and thanks for answering. I'm basically just trying to find a way to use the power of `...` in more complex scenarios and I'm well aware that this might not be the best approach ;-) Regarding your actual question: "Are you suggesting methods be dispatched based on the *contents* of ... [...]?" Yes, I guess currently I kind of do - but not on the argument *names* I'm not expecting functions to detect the argument *names* from `...`, but the relevant "argument containers" from which then the actual arguments should be extracted and used: I thought the *actual* arguments to be passed via `...` to subsequent functions/methods could be put into an "arguments container" (as a list so you could easily use them with `do.call(foo)`) that has a class that `foo` expects for its `...` argument (e.g. `ThreedotsForFoo`). What I would like to accomplish is that `foo` auto-detects those parts coming in via `...` that are *relevant* for itself (e.g. instances of the argument container `ThreedotsForFoo`), that it handles them in a proper way (i.e. extracting the *actual* arguments from the container) and that it passes `...` along to subsequently called functions. That's why I would need methods that use mix of regular formal arguments and `...`. Best regards, Janko On Thu, Nov 27, 2014 at 7:48 PM, Gabriel Becker wrote: > Janko, > > I'm not entirely sure I understand your proposal. Are you suggesting > methods be dispatched based on the *contents* of ... (ie which arguments > are in there)? This seems like it would be pretty different from how > dispatch behaves now, which is entirely class based. > > Even the dispatching based on ... via dots methods is class based, having > nothing to do AFAIK with the argument names. From ?dotsMethods > > A method selecting on “...” is specified by a single class in the call to > setMethod <http://127.0.0.1:11942/library/methods/help/setMethod>. If all > the actual arguments corresponding to “...” have this class, the > corresponding method is selected directly. > > Otherwise, the class of each argument and that class' superclasses are > computed, beginning with the first “...” argument. For the first argument, > eligible methods are those for any of the classes. For each succeeding > argument that introduces a class not considered previously, the eligible > methods are further restricted to those matching the argument's class or > superclasses. If no further eligible classes exist, the iteration breaks > out and the default method, if any, is selected. > > > No mention of argument name there. > > ~G > > On Thu, Nov 27, 2014 at 9:45 AM, Janko Thyson > wrote: > >> Dear List, >> >> I'm currently investigating if the argument dispatch mechanism based on >> `...` could somehow be "generalized" to scenarios that involve `r` >> recipients located across `c` calling stack layers *and* combined with the >> S4 method mechanism (for those interested see >> >> http://stackoverflow.com/questions/26963900/generalizing-three-dots-argument-dispatch-s4-methods-for-argument-set-i >> for an (conceptual) approach of how this could be realized). >> >> AFAICT, this would require that `...` can be *mixed* with other signature >> arguments, which is currently not supported as stated in `?dotsMethods`: >> >> Quote { >> Using "..." in a Signature >> >> Beginning with version 2.8.0 of R, S4 methods can be dispatched (selected >> and called) corresponding to the special argument “...”. Currently, “...” >> cannot be mixed with other formal arguments: either the signature of the >> generic function is “...” only, or it does not contain “...”. (This >> restriction may be lifted in a future version.) >> } >> >> Would it be possible to consider lifting this limitation soon? >> >> Thanks a lot to everyone maintaining R!! >> >> Janko >> >> [[alternative HTML version deleted]] >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> > > > > -- > Gabriel Becker > Graduate Student > Statistics Department > University of California, Davis > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Feature request: mixing `...` (three dots) with other formal arguments in S4 methods
Dear List, I'm currently investigating if the argument dispatch mechanism based on `...` could somehow be "generalized" to scenarios that involve `r` recipients located across `c` calling stack layers *and* combined with the S4 method mechanism (for those interested see http://stackoverflow.com/questions/26963900/generalizing-three-dots-argument-dispatch-s4-methods-for-argument-set-i for an (conceptual) approach of how this could be realized). AFAICT, this would require that `...` can be *mixed* with other signature arguments, which is currently not supported as stated in `?dotsMethods`: Quote { Using "..." in a Signature Beginning with version 2.8.0 of R, S4 methods can be dispatched (selected and called) corresponding to the special argument “...”. Currently, “...” cannot be mixed with other formal arguments: either the signature of the generic function is “...” only, or it does not contain “...”. (This restriction may be lifted in a future version.) } Would it be possible to consider lifting this limitation soon? Thanks a lot to everyone maintaining R!! Janko [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Workarounds/solutions to Rd file name conflict when extending a S4 method of some other package
Dear list, this is a re-post of my post to r-help on 2012-30-11. Duncan Murdoch did provide a great pointer to a possible workaround, but I'm still eager to check out other ways. So I hope it's okay to get this out on r-devel now as well: // IN SHORT // What are possible workarounds to "consolidate" documentation for S4 methods that are scattered across different packages (generic and some custom methods in one package, additional custom methods in another package) in a *single* Rd help file while using package 'roxygen2' to generate the actual Rd files? // ADDITIONAL INFORMATION // First of, here are the three facts that "cause" my problem: 1) I'd like the software, i.e. the packages, that I write to be as extendable as possible 2) I pretty much ended up using S4 functionality in everything I do 3) I'm a big fan of "in-file documentation" and package 'roxygen2' does a wonderful job in helping me out keeping my Rd help files synced That being said, it is a quite common scenario that some package (say 'pkga') contains the *generic* method/function 'foo()' as well as *some* custom methods (for different data types of the available signature arguments). Now, let's suppose that someone using 'pkga' and building a new package (say 'pkgb') would like to build upon the generic method 'pkga::foo()' and provide some more custom methods for it. When he sticks to the suggested workflow (especially with respect to the way the roxygen2 code is written), then R CMD check will rightly(!) complain that an Rd file with the respective name (generated by 'roxygenize()') already exists (because it is already part of 'pkga'). My question is hence twofold: 1) What would be possible workarounds that allow me to a) keep using 'roxygen2' and link documentation of pkga::foo() with that of pkgb::foo() (as they do belong together conecptionally) 2) Is there a need to address this problem on a higher level in the future? My feeling is that more people are starting to use S4 which, IMHO, is a good thing as it allows to systematically build upon code of other programmers. But then I guess we would need some sort of an "inter-package" check and/or help-file consolidation to present the user a single source of documentation for some S4 method. I tried to illustrate the problem with actual code in this post at Stackoverflow: http://stackoverflow.com/questions/13137912/rd-file-name-conflict-when-s4-generic-and-methods-are-not-in-the-same-package Best regards, Janko [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] "Ambiguous" variation of default environment in `getClasses()` (standard function vs. formal S4 method)
Dear list, This probably makes perfect sense from the language designers' perspective, but at least for me this was/is quite an interesting and unexpected behavior which I thought might be worth sharing: The default value of argument |where|in function |getClasses()|seems to vary depending on whether |getClasses()|is called inside a *standard R function*or a *formal S4 method*. It is controlled by |.externalCallerEnv()|, which seems to be "vulnerable" to /lazy evaluation/and/or an "altered" /lexical scoping/structure (possible introduced by the definition of a formals S4 method?) and thus causes the variation**. I found it quite hard to understand what's exactly going on as you need to manually debug `getClasses()` in order to find out what the default value of `where` (controlled by `|.externalCallerEnv()`) actually is in the various settings|. But that of course might as well be just me ;-) For those interested, I tried to illustrate the behavior in this SO post: http://stackoverflow.com/questions/12166645/ambiguous-variation-of-default-environment-in-getclasses-standard-function/12174390#12174390 Best regards, Janko Thyson [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Feature request: workaround for 'Sys.timezone()' issue for German MS-Windows
Dear list, I know this is *not* R's but Windows fault, at least for the German version. But: `Sys.timezone()' will return with an invalid time zone. I just wondered if there's a chance to implement an alternative, "OS-independent" way for querying the time zone corresponding to the country where a specific R session was launched. I've written a post on SO where I had a go at it, but it involves way to many steps: http://stackoverflow.com/questions/11347854/retrieve-time-zone-based-on-locale-country-information-in-an-os-independent-wa It'd be really great if someone could consider addressing this. Thank you very much, Janko Thyson __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] S4 Reference Classes: declaring public and private methods
Dear list, is there a way to declare public and private methods in S4 Reference Classes? If not, are there plans to add such a feature? You'll find a small code example of what I mean at Stackoverflow: http://stackoverflow.com/questions/11073253/oop-with-r-is-there-a-way-to-declare-public-and-private-methods-s4-reference-c Thanks a lot, Janko Thyson __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Possible bug in 'new()' for Reference Classes
Dear list, I think I stumbled across a little bug with respect to the standard initialization routine for Reference Classes. It seems that a field 'self' is treated as if it's name would be '.self' (which we know is reserved for the self reference of the instantiated object itself) and thus an error is thrown. If the field value is assigned in an explicit call after the instantiation via 'new()', everything works just fine: setRefClass("ClassInfo", fields=list( self="character", super="character", sub="character" ) ) new("ClassInfo", self="B", super="A", sub="C")# Error x <- new("ClassInfo", super="A", sub="C") x x$self <- "B" # Works x Best regards, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Implementing a "plugin" paradigm with R methods
i: # 1) 'do.explicit.clss = FALSE' implies that plugin methods have been defined #based on the 'unprocessed' class names for signature arguments, i.e. #'signature(ns="mypkg", link="foo", mount="default", plugin="punct", # src="character")' #instead of #'signature(ns="API_mypkg", link="API_foo", mount="API_default", # plugin="API_punct", src="character")' # 2) 'do.explicit.clss = TRUE' implies the use of the 'processed' class names setMethod( f=pluginProcessRef, signature=c(.self="Plugin"), function(.self, do.explicit.clss=FALSE, ...){ out <- NULL if(length(.self$ns)){ if(!do.explicit.clss){ rgx.subst <- "API_" ns <- gsub(rgx.subst, "", .self$ns) names(ns) <- NULL link <- gsub(rgx.subst, "", .self$link) names(link) <- NULL mount <- gsub(rgx.subst, "", .self$mount) names(mount) <- NULL plugin <- gsub(rgx.subst, "", .self$plugin) names(plugin) <- NULL if(!existsMethod( f="pluginExecute", signature=c(ns=ns, link=link, mount=mount, plugin=plugin, src=class(.self$src)) )){ stop("Invalid plugin") } .pluginExecute <- selectMethod( "pluginExecute", signature=c(ns=ns, link=link, mount=mount, plugin=plugin, src=class(.self$src)), useInherited=c(ns=FALSE, link=FALSE, mount=FALSE, plugin=FALSE, src=TRUE) ) out <- .pluginExecute(src=.self$src) } else { out <- pluginExecute(ns=new(.self$ns), link=new(.self$link), mount=new(.self$mount), plugin=new(.self$plugin), src=.self$src) } } return(out) } ) #+ # Define the actual plugin methods. For illustration, one using a implicit # and the other using explicit class names notation for signature arguments. # Unfortunately I don't know how to avoid warnings at this point; guess I can't setMethod(f=pluginExecute, signature=c(ns="mypkg", link="objectModify", mount="default", plugin="punct",src="character"), function(ns, link, mount, plugin, src, ...){ out <- gsub("[[:punct:]]", "", src) } ) setMethod(f=pluginExecute, signature=c(ns="API_mypkg", link="API_objectModify", mount="API_default", plugin="API_digit", src="character"), function(ns, link, mount, plugin, src, ...){ out <- gsub("[[:digit:]]", "", src) } ) showMethods("pluginExecute") #+ # Define the function/method that should be open for plugins foo <- function(plugin=pluginObjectCreate(), do.explicit.clss=FALSE, ...){ cat("Here: computations before plugin", sep="\n") cat(paste("Calling plugin '", class(plugin), "'", sep=""), sep="\n") out <- plugin$pluginProcess(do.explicit.clss=do.explicit.clss) cat("Here: computations after plugin", sep="\n") return(out) } #+ # Apply foo() foo( plugin=pluginObjectCreate(ns="mypkg", link="objectModify", mount="default", plugin="punct", src="string___123")) foo(plugin=pluginObjectCreate(ns="mypkg", link="objectModify", mount="default", plugin="digit", src="string123")) # No such plugin method as explicit class names have been used for 'digit foo(plugin=pluginObjectCreate(ns="mypkg", link="objectModify", mount="default", plugin="digit", src="string123"), do.explicit.clss=TRUE) # /APPROACH 6 r-devel -- On 24.08.2011 06:37, Martin Morgan wrote: On 08/23/2011 03:02 PM, Janko Thyson wrote: Dear list, I was wondering how to best implement some sort of a "plugin" paradigm using R methods and the dispatcher: Say we have a function/method ('foo') that does something useful, but that should be open for extension in ONE specific area by OTHERS using my package. Of course they could go ahead and write a whole new 'foo' One possibility is to write class / method pairs. The classes extend 'Plugin', and the methods are on generic 'plug', with the infrastructure
[Rd] Bug in 'setRefClass()' regarding how args in '...' are passed to 'setClass()'?
Dear list, in ?setRefClass it says that '...' can be used to supply other arguments that are passed to 'setClass()'. Yet, I think that's not true for argument 'prototype', but maybe I overlooked something: setClass("Plugin") setClass(Class="PluginDefault", contains="Plugin", representation=representation(.PRIMARY="function"), prototype=prototype(.PRIMARY=function(src) src) ) PluginDefault <- function() new("PluginDefault") PluginDefault() PluginDefault()$.PRIMARY# Desired prototype content #+ START A NEW R SESSION BEFORE CONTINUING setRefClass("Plugin") setRefClass(Class="PluginDefault", contains="Plugin", fields=list(.PRIMARY="function"), prototype=prototype(.PRIMARY=function(src) src) ) PluginDefault <- function() new("PluginDefault") PluginDefault() PluginDefault()$.PRIMARY # No prototype content Regards, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Implementing a "plugin" paradigm with R methods
Hi Martin, thanks a lot for the quick reply. I'll try your suggestions. Regards, Janko On 24.08.2011 06:37, Martin Morgan wrote: On 08/23/2011 03:02 PM, Janko Thyson wrote: Dear list, I was wondering how to best implement some sort of a "plugin" paradigm using R methods and the dispatcher: Say we have a function/method ('foo') that does something useful, but that should be open for extension in ONE specific area by OTHERS using my package. Of course they could go ahead and write a whole new 'foo' One possibility is to write class / method pairs. The classes extend 'Plugin', and the methods are on generic 'plug', with the infrastructure ## Approach 1: class / method pairs setClass("Plugin") setClass("DefaultPlugin", contains="Plugin") DefaultPlugin <- function() new("DefaultPlugin") setGeneric("plug", function(plugin, src) standardGeneric("plug"), signature="plugin", valueClass="character") setMethod(plug, "Plugin", function(plugin, src) { src }) foo <- function(src, plugin=DefaultPlugin()) { plug(plugin, src) } This is extended by writing class / method pairs setClass("Punct", contains="Plugin") Punct <- function() new("Punct") setMethod(plug, "Punct", function(plugin, src) { gsub("[[:punct:]]", "", src) }) setClass("Digit", contains="Plugin") Digit <- function() new("Digit") setMethod(plug, "Digit", function(plugin, src) { gsub("[[:digit:]]", "", src) }) The classes could have slots with state, accessible within the method. An easier-on-the-user approach might have the Plugin class contain or have slots of class "function". The user would only be obliged to provide an appropriate function. ## Approach 2: setClass("Plugin", prototype=prototype(function(src) { src }), contains="function") Plugin <- function() new("Plugin") setGeneric("foo", function(src, plugin) standardGeneric("foo")) setMethod(foo, c("character", "missing"), function(src, plugin) foo(src, Plugin())) setMethod(foo, c("character", "Plugin"), function(src, plugin) plugin(src)) ## 'Developer' classes setClass("Punct", prototype=prototype(function(src) { gsub("[[:punct:]]", "", src) }), contains="Plugin") Punct <- function() new("Punct") setClass("Digit", prototype=prototype(function(src) { gsub("[[:digit:]]", "", src) }), contains="Plugin") Digit <- function() new("Digit") ## General-purpose 'user' class setClass("User", contains="Plugin") User <- function(fun) new("User", fun) This could have syntax checking in the validity method to catch some mistakes early. In the S3 world, this is the approach taken by glm for its 'family' argument, for instance str(gaussian(). Martin method including the features they'd like to see, but that's not really necessary. Rather, they should be able to just write a new "plugin" method for that part of 'foo' that I'd like to open for such plugins. The way I chose below works, but generates warnings as my method has signature arguments that don't correspond to formal classes (which is totally fine). Of course I could go ahead and make sure that such "dummy" classes exist, but I was wondering if there's a better way. It'd be great if anyone could let me know how they handle "plugin" scenarios based on some sort of method dispatch! Thanks, Janko # CODE EXAMPLE # setGeneric(name="foo", signature=c("src"), function(src, ...) standardGeneric("foo")) setGeneric(name="plugin", signature=c("src", "link", "plugin"), function(src, link, plugin, ...) standardGeneric("plugin") ) setMethod(f="plugin", signature=signature(src="character", link="foo", plugin="punct"), function(src, link, plugin, ...){ out <- gsub("[[:punct:]]", "", src) return(out) } ) setMethod(f="plugin", signature=signature(src="character", link="foo", plugin="digit"), function(src, link, plugin, ...){ out <- gsub("[[:digit:]]", "", src) return(out) } ) setMethod(f="foo", signature=signature(src="character"), function(src, plugin=NULL, ...){ if(!is.null(plugin)){ if(!existsMethod(f="plugin", signature=c(src=class(src), link="foo", plugin=plugin) )){ stop("Invalid plugin") } .plugin <- selectMethod( "plugin", signature=c(src=class(src), link="foo", plugin=plugin), useInherited=c(src=TRUE, plugin=FALSE) ) out <- .plugin(src=src) } else { out <- paste("Hello world: ", src, sep="") } return(out) } ) foo(src="Teststring:-1234_56/") foo(src="Teststring:-1234_56/", plugin="punct") foo(src="Teststring:-1234_56/", plugin="digit") __ 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
[Rd] Implementing a "plugin" paradigm with R methods
Dear list, I was wondering how to best implement some sort of a "plugin" paradigm using R methods and the dispatcher: Say we have a function/method ('foo') that does something useful, but that should be open for extension in ONE specific area by OTHERS using my package. Of course they could go ahead and write a whole new 'foo' method including the features they'd like to see, but that's not really necessary. Rather, they should be able to just write a new "plugin" method for that part of 'foo' that I'd like to open for such plugins. The way I chose below works, but generates warnings as my method has signature arguments that don't correspond to formal classes (which is totally fine). Of course I could go ahead and make sure that such "dummy" classes exist, but I was wondering if there's a better way. It'd be great if anyone could let me know how they handle "plugin" scenarios based on some sort of method dispatch! Thanks, Janko # CODE EXAMPLE # setGeneric(name="foo", signature=c("src"), function(src, ...) standardGeneric("foo")) setGeneric(name="plugin", signature=c("src", "link", "plugin"), function(src, link, plugin, ...) standardGeneric("plugin") ) setMethod(f="plugin", signature=signature(src="character", link="foo", plugin="punct"), function(src, link, plugin, ...){ out <- gsub("[[:punct:]]", "", src) return(out) } ) setMethod(f="plugin", signature=signature(src="character", link="foo", plugin="digit"), function(src, link, plugin, ...){ out <- gsub("[[:digit:]]", "", src) return(out) } ) setMethod(f="foo", signature=signature(src="character"), function(src, plugin=NULL, ...){ if(!is.null(plugin)){ if(!existsMethod(f="plugin", signature=c(src=class(src), link="foo", plugin=plugin) )){ stop("Invalid plugin") } .plugin <- selectMethod( "plugin", signature=c(src=class(src), link="foo", plugin=plugin), useInherited=c(src=TRUE, plugin=FALSE) ) out <- .plugin(src=src) } else { out <- paste("Hello world: ", src, sep="") } return(out) } ) foo(src="Teststring:-1234_56/") foo(src="Teststring:-1234_56/", plugin="punct") foo(src="Teststring:-1234_56/", plugin="digit") __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Increase transparency: suggestion on how to avoid namespaces and/or unnecessary overwrites of existing functions
aDear list, I'm aware of the fact that I posted on something related a while ago, but I just can't sweat this off and would like to ask your for an opinion: The problem: Namespaces are great, but they don't resolve certain conflicts regarding name clashes. There are more and more people out there trying to come up with their own R packages, which is great also! Yet, it becomes more and more likely that programmers will choose identical names for their exported functions and/or that they add functionality to existing function (i.e. overwriting existing functions). The whole process of which packages overwrite which functions is somewhat obscure and in addition depends on their order in the search path. On the other hand, it is not possible to use "namespace" functionality (i.e. 'namespace::fun()'; also less efficient than direct call; see illustration below) during early stages of the development process (i.e. the package is not finished yet) as there is no namespace available yet. I know of at least two cases where such overwrites (I think it's called masking, right?) led to some confusion at our chair: 1) loading package forecast overwrites certain functions in stats which made some code refactoring necessary 2) loading package 'R.utils' followed by package 'roxygen' overwrites 'parse.default()' which results in errors for something like 'eval(parse(text="a <- 1"))' ; see illustration below) And I'm sure the community could come up with lots more of such scenarios. Suggestions: 1) In order to avoid name clashes/unintended overwrites, how about switching to a coding paradigm that explicitly (and automatically) includes a package's name in all its functions' names once code is turned into a real package? E.g., getting used to "preemptively" type 'package_fun()' or 'package.fun()' instead of just 'fun()'. Better to be save than sorry, right? This could be realized pretty easily (see example below) and, IMHO, would significantly increase transparency. 2) In order to avoid intended (but for the user often pretty obscure) overwrites of existing functions, we could use the same mechanism together with the "rule": just don't provide any functions that overwrite existing ones, rather prepend your version of that function with your package name and leave it up to the user which version he wants to call. At the moment, all of this is probably not that big of a deal yet, but my suggestion has more of a mid-term/long-term character. Below you find a little illustration. I'm probably asking too much, but it'd be great if we could get a little discussion going on how to improve the way of loading packages! Best regards and thanks for R and all it's packages! Janko # PROOF OF CONCEPT # 1) PROBLEM # IMHO, with the number of packages submitted to CRAN constantly increasing, # over time we will be likely to see problems with respect to name clashes. # The main reasons I see for this are the following: # a) package developers picking identical names for their exported functions # b) package developers overwriting base functions in order to add functionality #to existing functions # c) ... # # This can create scenarios in which the user might not exactly know that # he/she is using a 'modified' version of a specific function. More so, the user # needs to carefully read the description of each new package he plans # to use in order to find out which functions are exported and which existing # functions might be overwritten. This in turn might imply that the user's # existing code needs to be refactored (i.e. instead of using 'fun()' it # might now be necessary to type 'namespace::fun()' to be sure that the desired # function is called). # 2) SUGGESTED SOLUTION # That being said, why don't we switch to a 'preemptive' coding paradigm # where the default way of calling functions includes the specification of # its namespace? In principle, the functionality offered by 'namespace::fun()' # gets the job done. # BUT: # a) it is slower compared to the direct way of calling a function. #(see illustration below). # b) this option is not available througout the development process of a package #as there is no namespace yet and there's no way to emulate one. This in #turn means that even though a package developer would buy into strictly #using 'mypkg::fun()' throughout his package code, he can only do so at the #very final stage of the process RIGHT before turning his code into a #working package (when he's absolutely sure everything is working as planned). #For debugging he would need to go back to using 'fun()'. Pretty cumbersome. # So how about simply automatically prepending a given function's name with # the package's name for each package that is build (e.g. 'pkg.fun()' or # '
[Rd] Fwd: Bug: argument 'lib.loc' not passed on appropriately in 'library()'?
Sorry, embarrassing stupid error: of course '.libPaths(path.r.lib)' will do the trick for me. Regards, Janko Original Message Subject:Bug: argument 'lib.loc' not passed on appropriately in 'library()'? Date: Thu, 18 Aug 2011 19:31:02 +0200 From: Janko Thyson To: org, r-devel@r-project. Dear list, I'm experimenting with setting up custom 'lib' and 'destdir' directories for my R packages. It seems to me that 'library()' does handle a custom 'lib.loc' argument the way it should for an arbitrary package but NOT for its dependencies on other packages. The latter are looked for in the default lib path (~/R/R-2.x.x/library) and NOT in the custom lib path. Below is a little code example illustrating the error I'm getting. It'd be great if someone could validate this. Thanks a lot for any comments, Janko ### CODE EXAMPLE ### # Package that I'm sure of that it's not already installed and has dependencies pkg<- "rworldmap" # Making sure that dependencies are not available in the default library remove.packages("sp") remove.packages("maptools") remove.packages("foreign") remove.packages("lattice") # Setting custom lib and destdir path.r.lib<- "C:/temp/R/library" dir.create(path.r.lib, recursive=TRUE, showWarning=FALSE) path.r.destdir<- "C:/temp/R/destdir" dir.create(path.r.destdir, recursive=TRUE, showWarning=FALSE) # Core processing try.res<- try( eval(substitute( library(PKG, lib.loc=path.r.lib, verbose=FALSE), list(PKG=pkg) )), silent=TRUE ) if(inherits(try.res, "try-error")){ msg<- c( paste("Required package '", pkg, "' not available locally", sep=""), paste("Looking for package '", pkg, "' in remote repository", sep="") ) cat(msg, sep="\n") install.packages( pkg, repos=getOption("repos"), lib=path.r.lib, destdir=path.r.destdir, dependencies="Depends" ) eval(substitute( library(PKG, lib.loc=path.r.lib, verbose=FALSE), list(PKG=pkg) )) # Here's where the error occurs. Seems to me that 'lib.loc' is not really # passed on appropriately within 'library()', but instead the default lib path # is used to look for dependencies. } [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Bug: argument 'lib.loc' not passed on appropriately in 'library()'?
Dear list, I'm experimenting with setting up custom 'lib' and 'destdir' directories for my R packages. It seems to me that 'library()' does handle a custom 'lib.loc' argument the way it should for an arbitrary package but NOT for its dependencies on other packages. The latter are looked for in the default lib path (~/R/R-2.x.x/library) and NOT in the custom lib path. Below is a little code example illustrating the error I'm getting. It'd be great if someone could validate this. Thanks a lot for any comments, Janko ### CODE EXAMPLE ### # Package that I'm sure of that it's not already installed and has dependencies pkg <- "rworldmap" # Making sure that dependencies are not available in the default library remove.packages("sp") remove.packages("maptools") remove.packages("foreign") remove.packages("lattice") # Setting custom lib and destdir path.r.lib <- "C:/temp/R/library" dir.create(path.r.lib, recursive=TRUE, showWarning=FALSE) path.r.destdir <- "C:/temp/R/destdir" dir.create(path.r.destdir, recursive=TRUE, showWarning=FALSE) # Core processing try.res <- try( eval(substitute( library(PKG, lib.loc=path.r.lib, verbose=FALSE), list(PKG=pkg) )), silent=TRUE ) if(inherits(try.res, "try-error")){ msg <- c( paste("Required package '", pkg, "' not available locally", sep=""), paste("Looking for package '", pkg, "' in remote repository", sep="") ) cat(msg, sep="\n") install.packages( pkg, repos=getOption("repos"), lib=path.r.lib, destdir=path.r.destdir, dependencies="Depends" ) eval(substitute( library(PKG, lib.loc=path.r.lib, verbose=FALSE), list(PKG=pkg) )) # Here's where the error occurs. Seems to me that 'lib.loc' is not really # passed on appropriately within 'library()', but instead the default lib path # is used to look for dependencies. } __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Ref Classes: bug with using '.self' within initialize methods?
Dear list, I'm wondering if the following error I'm getting is a small bug in the Reference Class paradigm or if it makes perfect sense. When you write an explicit initialize method for a Ref Class, can you then make use of '.self' WITHIN this initialize method just as you would once an object of the class has actually been initialized? Because it seems to me that you can not. Below is an example that shows that calling '.self$someInitFoo()' within the initialize method for 'MyClass' does not work (see section "METHODS" in example below). Instead I have to go with 'someInitFooRefInner(.self=.Object, ...)' (see section "UPDATED METHOD" in example below). Yet, this is only possible because there actually IS such a method (I try to stick to the recommendations at ?setRefClass where it says: "Reference methods should be kept simple; if they need to do some specialized *R* computation, that computation should use a separate *R* function that is called from the reference method") The same problem occurs when, say 'someInitFoo()' calls yet another Ref Class method (as is the case in the example below with a call to '.self$someFoo()'). Is this a desired behavior? Thanks for any clarifying comments! Janko # CODE EXAMPLE # # CLASSES setRefClass( Class="MyVirtual", contains=c("VIRTUAL"), methods=list( initialize=function(...){ callSuper(...) return(.self) }, someInitFoo=function(flds, ...){ someInitFooRefInner( .self=.self, flds=flds ) } ) ) GENERATOR <- setRefClass( Class="MyClass", contains=c("MyVirtual"), fields=list( A="character", B="numeric" ), methods=list( someFoo=function(...){ someFooRefInner(.self=.self, ...) } ) ) # / # GENERICS setGeneric(name="someInitFooRefInner", def=function(.self, ...) standardGeneric("someInitFooRefInner"), signature=c(".self") ) setGeneric(name="someFooRefInner", def=function(.self, ...) standardGeneric("someFooRefInner"), signature=c(".self") ) # / # METHODS setMethod( f="someInitFooRefInner", signature=signature(.self="MyVirtual"), definition=function(.self, flds, ...){ print("Trying to call '.self$someFoo()") try(.self$someFoo()) print("Trying to call 'someFooRefInner(.self=.self)") try(someFooRefInner(.self=.self)) return(flds) } ) setMethod( f="someFooRefInner", signature=signature(.self="MyVirtual"), definition=function(.self, ...){ print("hello world!") } ) setMethod( f="initialize", signature=signature(.Object="MyVirtual"), definition=function(.Object, GENERATOR=NULL, ...){ # MESSAGE if(class(.Object) == "MyVirtual"){ cat(paste("initializing object of class '", class(.Object), "'", sep=""), sep="\n") } else { cat(paste("initializig object of class'", class(.Object), "' inheriting from class 'MyVirtual'", sep=""), sep="\n") } # / # GET GENERATOR OBJECT if(is.null(GENERATOR)){ GENERATOR <- getRefClass(class(.Object)) } flds <- names(GENERATOR$fields()) .Object$someInitFoo( flds=flds, ... ) return(.Object) } ) # / x <- GENERATOR$new() # UPDATED METHOD setMethod( f="initialize", signature=signature(.Object="MyVirtual"), definition=function(.Object, GENERATOR=NULL, ...){ # MESSAGE if(class(.Object) == "MyVirtual"){ cat(paste("initializing object of class '", class(.Object), "'", sep=""), sep="\n") } else { cat(paste("initializig object of class'", class(.Object), "' inheriting from class 'MyVirtual'", sep=""), sep="\n") } # / # GET GENERATOR OBJECT if(is.null(GENERATOR)){ GENERATOR <- getRefClass(class(.Object)) } flds <- names(GENERATOR$fields()) someInitFooRefInner(.self=.Object, flds=flds, ...) return(.Object) } ) # / x <- GENERATOR$new() [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Require of gWidgetsRGtk2 fails: RGtk2.dll can't be found, but it's there
Thanks Tony, that's something John Verzani suggested to me as well. I don't think there is any other version on my PATH as I usually try to be pretty rigid about updating it both ways (installing new stuff, getting rid of old stuff), but he suggested that there might be older versions of a GTK2 installation floating around my system somewhere. Thanks a lot for the pointer! Janko On 12.06.2011 16:57, Tony Plate wrote: > I also had frustrations trying to use libary RGtk2 under Windows XP. > > I kept getting the message > "unable to load shared object > C:\R\site-library\RGtk2\libs\i386\RGtk2.dll" > even though it was on my path. > > Uninstalling and reinstalling various versions of GTK2, both through R > and outside R, many times, including rebooting Windows, did not help. > > With the help of some comments on R-help (Neil Rice, Mar 7, 2011), I > found that > there was another conflicting version of zlib1.dll in a directory on > my PATH. > Removing that directory from the path (inside R) fixed the problem and > I am able > to run RGtk2 now. > > Here's an R expression to look for copies of the various DLLs that > GTK2 uses (change "c:/GTK2-Runtime/bin/" to be appropriate for your > system): > > > for (dll in list.files("c:/GTK2-Runtime/bin/", pattern="*.dll$")) > print(with(list(x=file.path(strsplit(Sys.getenv("PATH"), ";")[[1]], > dll)), x[file.exists(x)])) > [1] "C:\\GTK2-Runtime\\bin/freetype6.dll" > [1] "C:\\GTK2-Runtime\\bin/intl.dll" > [1] "C:\\GTK2-Runtime\\bin/libatk-1.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libcairo-2.dll" > [1] "C:\\GTK2-Runtime\\bin/libcairo-gobject-2.dll" > [1] "C:\\GTK2-Runtime\\bin/libcairo-script-interpreter-2.dll" > [1] "C:\\GTK2-Runtime\\bin/libexpat-1.dll" > [1] "C:\\GTK2-Runtime\\bin/libfontconfig-1.dll" > [1] "C:\\GTK2-Runtime\\bin/libgailutil-18.dll" > [1] "C:\\GTK2-Runtime\\bin/libgdk-win32-2.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libgdk_pixbuf-2.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libgio-2.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libglib-2.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libgmodule-2.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libgobject-2.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libgthread-2.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libgtk-win32-2.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libpango-1.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libpangocairo-1.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libpangoft2-1.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libpangowin32-1.0-0.dll" > [1] "C:\\GTK2-Runtime\\bin/libpng14-14.dll" > [1] "C:\\GTK2-Runtime\\bin/zlib1.dll" > > > > If there are any lines beginning with [2] in the output, there are > multiple > versions of DLLs and these are potential problems (check that either the > DLLs are the same version, or that the GTK2 version is ahead on the path). > > Note that is is not sufficient that the GTK2 library is on the path -- > it has > to be ahead of other path components that have conflicting DLLs. > > > On 6/11/2011 8:59 PM, Michael Lawrence wrote: >> I'm working on a mechanism that will download GTK+ (the official zip files) >> into a predetermined location and put that location in front of the other >> paths at load time. Hopefully this will resolve these continuing issues. >> >> Michael >> >> On Fri, Jun 10, 2011 at 6:07 AM, Janko Thyson< >> janko.thyson.rst...@googlemail.com> wrote: >> >>> Okay, at least some positive result today (language issue ;-)) >>> >>> Thanks for trying. Seems like GTK2 and me are not meant to be ... >>> >>> Regards, >>> Janko >>> >>> >>> On 10.06.2011 14:36, Prof Brian Ripley wrote: >>> >>>> It is a Microsoft error message, so your Windows is translating it, not R. >>>> It does say 'The specified module' in English Windows, without saying who >>>> specified the module (but it does often produce a popup naming the module). >>>> >>>> I've no better idea what your problem is: the @ReadMe instructions work >>>> for me, Uwe on winbuilder and in our teaching lab (and the advice in RGtk2 >>>> does not). >>>> >>>> On Fri, 10 Jun 2011, Janko Thyson wrote: >>>> >>>> On 10.06.2011 13:18, Prof Brian Ripley wrote: >>>>> On Fri, 10 Jun 2011, Janko Thyson wrote: >>>>> >>>>>
Re: [Rd] Require of gWidgetsRGtk2 fails: RGtk2.dll can't be found, but it's there
Okay, at least some positive result today (language issue ;-)) Thanks for trying. Seems like GTK2 and me are not meant to be ... Regards, Janko On 10.06.2011 14:36, Prof Brian Ripley wrote: It is a Microsoft error message, so your Windows is translating it, not R. It does say 'The specified module' in English Windows, without saying who specified the module (but it does often produce a popup naming the module). I've no better idea what your problem is: the @ReadMe instructions work for me, Uwe on winbuilder and in our teaching lab (and the advice in RGtk2 does not). On Fri, 10 Jun 2011, Janko Thyson wrote: On 10.06.2011 13:18, Prof Brian Ripley wrote: On Fri, 10 Jun 2011, Janko Thyson wrote: Dear list, I've been trying to get gWidgets/gWidgetsRGtk2 to run every other month for a while, but somehow I simply can't figure out what's going wrong. Your subject line indicates your confusion. It does not say RGtk2.dll cannot be found (at least, the English version of the message does not say so). What it means is that RGtk2.dll or one of the DLLs it depends on cannot be found. See the instructions at http://cran.r-project.org/bin/windows/contrib/2.13/@ReadMe It is Microsoft's error message, not ours. Thanks for your answer. I followed the advice in the readme file and installed http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.0-201010 16_win32.zip Previously I made sure that all other previously installed GTK+ runtime environments were removed and that the windows PATH reflects the correct path to the "new" GTK+ files. I also made sure I started a new R session before trying 'require(gWidgetsRGtk2)' again. Yet, the same error. More precisely, a dialog box pops up asking me to install GTK+ or not. That's what's confusing me as well: the package's recommendation with respect to the version of an GTK+ runtime environment is somewhat out-of-sync with the advice in the readme, even though it the version is fairly recent (2011-04-30) Sorry for the german part in the error message, but I wasn't able to get it all to English (tried language = en in Rconsole file, setting up a Renviron.site with LANGUAGE=en, setting Sys.setenv("LANGUAGE"="en") and Sys.setenv("LC_ALL"="en") to no avail; not a good R day today ;-)). I freely translated it for you: Loading required package: gWidgetsRGtk2 Loading required package: gWidgets Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'R:/Apps/R/R-2.13.0/library/RGtk2/libs/i386/RGtk2.dll': LoadLibrary failure: the specified module could not be found. Failed to load RGtk2 dynamic library, attempting to install it. Learn more about GTK+ at http://www.gtk.org If the package still does not load, please ensure that GTK+ is installed and that it is on your PATH environment variable IN ANY CASE, RESTART R BEFORE TRYING TO LOAD THE PACKAGE AGAIN Error : .onAttach failed in attachNamespace() for 'gWidgetsRGtk2', details: call: .Call(name, ..., PACKAGE = PACKAGE) error: C symbol name "S_gtk_icon_factory_new" not in DLL for package "RGtk2" Do you have any other idea what I might be doing wrong? Regards, Janko I tried several distributions of the GTK runtime environment for Windows (http://downloads.sourceforge.net/gladewin32/gtk-2.12.9-win32-1.exe as described in the package's vignette,http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.1-20101 227_win32.zip) I also included GTK in my Windows PATH. Yet, when I run 'require(gWidgetsRGtk2)', R complains that the RGtk2.dll can't be found/loaded (see below). But this file definitely exists. I'm running R-2.13.0 from a USB Device but made sure that args 'destdir' and 'lib' are set propperly in 'install.packages'. Loading required package: gWidgetsRGtk2 Loading required package: gWidgets Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'R:/Apps/R/R-2.13.0/library/RGtk2/libs/i386/RGtk2.dll': LoadLibrary failure: Das angegebene Modul wurde nicht gefunden. Failed to load RGtk2 dynamic library, attempting to install it. Learn more about GTK+ at http://www.gtk.org If the package still does not load, please ensure that GTK+ is installed and that it is on your PATH environment variable IN ANY CASE, RESTART R BEFORE TRYING TO LOAD THE PACKAGE
Re: [Rd] Require of gWidgetsRGtk2 fails: RGtk2.dll can't be found, but it's there
On 10.06.2011 14:40, Gabor Grothendieck wrote: On Fri, Jun 10, 2011 at 8:31 AM, Janko Thyson wrote: On 10.06.2011 13:00, Gabor Grothendieck wrote: On Fri, Jun 10, 2011 at 6:04 AM, Janko Thyson wrote: Dear list, I've been trying to get gWidgets/gWidgetsRGtk2 to run every other month for a while, but somehow I simply can't figure out what's going wrong. 1. Use the automatically installed GTk2, not some other version. Thanks for answering. I didn't even know there GTk2 already ships with R. Prof. Brian Ripley linked me to the readme file with recommendations with respect to an GTK2 distribution to use: "What it means is that RGtk2.dll or one of the DLLs it depends on cannot be found. See the instructions at http://cran.r-project.org/bin/windows/contrib/2.13/@ReadMe " 2. Note that the automatically installed one will be at ...\GTk2-runtime\bin and that will be put at the *end* of your PATH. Change it so that its at the beginning of your PATH to be sure its not picking up something else. My R distribution does not seem to have such a directory (standard windows R-2.13.0 installer from CRAN) How do I manage to have this ...\GTk2-runtime\bin directory available? #1 is referring to the fact that when you run RGTk2 it will ask you if you want it to install GTk2. Say yes and let it install that version to be sure you are using the right one. If you install it yourself manually instead you could very easily install the wrong version. The only problem with the automatic installation is that it puts the GTk2 dll's at the end of your PATH so you can't be sure that something else on your path (such as graphviz which has its own potentially conflicting dll's) won't interfere. To fix that change the PATH so that GTk2 is at the beginning (or at least before anything else that could interere). Hm, I did install GTK2 via the automatic installation now (choosing to put the DLLs in the /bin directory). The problem is, that R keeps asking me to repeat this step (the dialog box) every time I try to load (in new R sessions) either RGTk2 or gWidgetsRGtk2 displaying the same error: Loading required package: gWidgetsRGtk2 Loading required package: gWidgets Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'R:/Apps/R/R-2.13.0/library/RGtk2/libs/i386/RGtk2.dll': LoadLibrary failure: The specified module could not be found. Failed to load RGtk2 dynamic library, attempting to install it. Learn more about GTK+ at http://www.gtk.org If the package still does not load, please ensure that GTK+ is installed and that it is on your PATH environment variable IN ANY CASE, RESTART R BEFORE TRYING TO LOAD THE PACKAGE AGAIN Error : .onAttach failed in attachNamespace() for 'gWidgetsRGtk2', details: call: .Call(name, ..., PACKAGE = PACKAGE) error: C symbol name "S_gtk_icon_factory_new" not in DLL for package "RGtk2" I also tried it on a different machine running Windows 7 and R-2.13.0. :-/ Do you have any other idea? Thanks a lot, Janko Thanks a lot, Janko 3. If you are changing the path through the control panel and starting R from the command line note that your new path won't be picked up in old command line sessions so start a new command line session to start R. 4. When you start a new R session double check that the automatically installed ...\GTk2-runtime\bin is at the beginning of your path: strsplit(Sys.getenv("PATH"), ";")[[1]] -- Janko Thyson janko.thy...@googlemail.com Jesuitenstraße 3 D-85049 Ingolstadt Mobile: +49 (0)176 83294257 This e-mail and any attachment is for authorized use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Require of gWidgetsRGtk2 fails: RGtk2.dll can't be found, but it's there
On 10.06.2011 13:00, Gabor Grothendieck wrote: > On Fri, Jun 10, 2011 at 6:04 AM, Janko Thyson > wrote: >> Dear list, >> >> I've been trying to get gWidgets/gWidgetsRGtk2 to run every other month for >> a while, but somehow I simply can't figure out what's going wrong. >> > 1. Use the automatically installed GTk2, not some other version. Thanks for answering. I didn't even know there GTk2 already ships with R. Prof. Brian Ripley linked me to the readme file with recommendations with respect to an GTK2 distribution to use: "What it means is that RGtk2.dll or one of the DLLs it depends on cannot be found. See the instructions at http://cran.r-project.org/bin/windows/contrib/2.13/@ReadMe " > 2. Note that the automatically installed one will be at > ...\GTk2-runtime\bin and that will be put at the *end* of your PATH. > Change it so that its at the beginning of your PATH to be sure its not > picking up something else. My R distribution does not seem to have such a directory (standard windows R-2.13.0 installer from CRAN) How do I manage to have this ...\GTk2-runtime\bin directory available? Thanks a lot, Janko > 3. If you are changing the path through the control panel and starting > R from the command line note that your new path won't be picked up in > old command line sessions so start a new command line session to start > R. > > 4. When you start a new R session double check that the automatically > installed ...\GTk2-runtime\bin is at the beginning of your path: > > strsplit(Sys.getenv("PATH"), ";")[[1]] > > -- *Janko Thyson* janko.thy...@googlemail.com <mailto:janko.thy...@googlemail.com> Jesuitenstraße 3 D-85049 Ingolstadt Mobile: +49 (0)176 83294257 This e-mail and any attachment is for authorized use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Require of gWidgetsRGtk2 fails: RGtk2.dll can't be found, but it's there
On 10.06.2011 13:18, Prof Brian Ripley wrote: > On Fri, 10 Jun 2011, Janko Thyson wrote: > >> Dear list, >> >> I've been trying to get gWidgets/gWidgetsRGtk2 to run every other >> month for a while, but somehow I simply can't figure out what's going >> wrong. > > Your subject line indicates your confusion. It does not say RGtk2.dll > cannot be found (at least, the English version of the message does not > say so). > > What it means is that RGtk2.dll or one of the DLLs it depends on > cannot be found. See the instructions at > http://cran.r-project.org/bin/windows/contrib/2.13/@ReadMe > > It is Microsoft's error message, not ours. Thanks for your answer. I followed the advice in the readme file and installed http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.0-20101016_win32.zip Previously I made sure that all other previously installed GTK+ runtime environments were removed and that the windows PATH reflects the correct path to the "new" GTK+ files. I also made sure I started a new R session before trying 'require(gWidgetsRGtk2)' again. Yet, the same error. More precisely, a dialog box pops up asking me to install GTK+ or not. That's what's confusing me as well: the package's recommendation with respect to the version of an GTK+ runtime environment is somewhat out-of-sync with the advice in the readme, even though it the version is fairly recent (2011-04-30) Sorry for the german part in the error message, but I wasn't able to get it all to English (tried language = en in Rconsole file, setting up a Renviron.site with LANGUAGE=en, setting Sys.setenv("LANGUAGE"="en") and Sys.setenv("LC_ALL"="en") to no avail; not a good R day today ;-)). I freely translated it for you: Loading required package: gWidgetsRGtk2 Loading required package: gWidgets Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'R:/Apps/R/R-2.13.0/library/RGtk2/libs/i386/RGtk2.dll': LoadLibrary failure: the specified module could not be found. Failed to load RGtk2 dynamic library, attempting to install it. Learn more about GTK+ at http://www.gtk.org If the package still does not load, please ensure that GTK+ is installed and that it is on your PATH environment variable IN ANY CASE, RESTART R BEFORE TRYING TO LOAD THE PACKAGE AGAIN Error : .onAttach failed in attachNamespace() for 'gWidgetsRGtk2', details: call: .Call(name, ..., PACKAGE = PACKAGE) error: C symbol name "S_gtk_icon_factory_new" not in DLL for package "RGtk2" Do you have any other idea what I might be doing wrong? Regards, Janko > >> >> I tried several distributions of the GTK runtime environment for >> Windows >> (http://downloads.sourceforge.net/gladewin32/gtk-2.12.9-win32-1.exe >> as described in the package's vignette, >> http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.1-20101227_win32.zip) >> >> I also included GTK in my Windows PATH. >> >> Yet, when I run 'require(gWidgetsRGtk2)', R complains that the >> RGtk2.dll can't be found/loaded (see below). But this file definitely >> exists. I'm running R-2.13.0 from a USB Device but made sure that >> args 'destdir' and 'lib' are set propperly in 'install.packages'. >> >> Loading required package: gWidgetsRGtk2 >> Loading required package: gWidgets >> Error in inDL(x, as.logical(local), as.logical(now), ...) : >> unable to load shared object >> 'R:/Apps/R/R-2.13.0/library/RGtk2/libs/i386/RGtk2.dll': >> LoadLibrary failure: Das angegebene Modul wurde nicht gefunden. >> >> Failed to load RGtk2 dynamic library, attempting to install it. >> Learn more about GTK+ at http://www.gtk.org >> If the package still does not load, please ensure that GTK+ is >> installed and that it is on your PATH environment variable >> IN ANY CASE, RESTART R BEFORE TRYING TO LOAD THE PACKAGE AGAIN >> Error : .onAttach failed in attachNamespace() for 'gWidgetsRGtk2', >> details: >> call: .Call(name, ..., PACKAGE = PACKAGE) >> error: C symbol name "S_gtk_icon_factory_new" not in DLL for package >> "RGtk2" >> >> Best regards, >> Janko >> >> R version 2.13.0 (2011-04-13) >> Platform: i386-pc-mingw32/i386 (32-bit) >> >> locale: >> [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 >> [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C >> [5] LC_TIME=German_Germany.1252 >> >> attached base packages: >> [1] stats graphics grDevices utils dat
[Rd] Require of gWidgetsRGtk2 fails: RGtk2.dll can't be found, but it's there
Dear list, I've been trying to get gWidgets/gWidgetsRGtk2 to run every other month for a while, but somehow I simply can't figure out what's going wrong. I tried several distributions of the GTK runtime environment for Windows (http://downloads.sourceforge.net/gladewin32/gtk-2.12.9-win32-1.exe as described in the package's vignette, http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.1-20101227_win32.zip) I also included GTK in my Windows PATH. Yet, when I run 'require(gWidgetsRGtk2)', R complains that the RGtk2.dll can't be found/loaded (see below). But this file definitely exists. I'm running R-2.13.0 from a USB Device but made sure that args 'destdir' and 'lib' are set propperly in 'install.packages'. Loading required package: gWidgetsRGtk2 Loading required package: gWidgets Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'R:/Apps/R/R-2.13.0/library/RGtk2/libs/i386/RGtk2.dll': LoadLibrary failure: Das angegebene Modul wurde nicht gefunden. Failed to load RGtk2 dynamic library, attempting to install it. Learn more about GTK+ at http://www.gtk.org If the package still does not load, please ensure that GTK+ is installed and that it is on your PATH environment variable IN ANY CASE, RESTART R BEFORE TRYING TO LOAD THE PACKAGE AGAIN Error : .onAttach failed in attachNamespace() for 'gWidgetsRGtk2', details: call: .Call(name, ..., PACKAGE = PACKAGE) error: C symbol name "S_gtk_icon_factory_new" not in DLL for package "RGtk2" Best regards, Janko R version 2.13.0 (2011-04-13) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] LC_TIME=German_Germany.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] gWidgets_0.0-44 loaded via a namespace (and not attached): [1] gWidgetsRGtk2_0.0-74 RGtk2_2.20.12tools_2.13.0 > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Rtools (Windows XP): what dir is meant by "R source directory"?
On 09.06.2011 15:58, Uwe Ligges wrote: > > > On 09.06.2011 15:07, Janko Thyson wrote: >> Dear list, >> >> thanks for providing such a great thing as the Rtools! Everytime I >> install it, though, I'm somewhat "puzzled" when it comes to the section >> "Select R Source Home Directory" (32 bit and 64 builds). >> Is the folder that I need to specify here >> a) simply the root folder of my R installation (e.g. C:/R/R-2.13.0), >> b) a subfolder of the above R installation folder (e.g. >> C:/R/R-2.13.0/src, C:/R/R-2-13.0/bin/src or C:/R/R-2-13.0/bin/i386/src), >> c) or does this just come into play when I try to build R from source, >> i.e. the folder where I would put the R tar.gz file? > > > Yes, c) is the answer. > > Uwe Thanks for the answer! > >> I always choose the paths C:\R\R-2.13.0\bin\i386\src (32 bit) and >> C:\R\R-2.13.0\bin\src (64 bit). Would this be okay? >> >> Thanks a lot for helping me out on this, >> Janko >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > -- *Janko Thyson* janko.thy...@googlemail.com <mailto:janko.thy...@googlemail.com> Jesuitenstraße 3 D-85049 Ingolstadt Mobile: +49 (0)176 83294257 This e-mail and any attachment is for authorized use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Rtools (Windows XP): what dir is meant by "R source directory"?
Dear list, thanks for providing such a great thing as the Rtools! Everytime I install it, though, I'm somewhat "puzzled" when it comes to the section "Select R Source Home Directory" (32 bit and 64 builds). Is the folder that I need to specify here a) simply the root folder of my R installation (e.g. C:/R/R-2.13.0), b) a subfolder of the above R installation folder (e.g. C:/R/R-2.13.0/src, C:/R/R-2-13.0/bin/src or C:/R/R-2-13.0/bin/i386/src), c) or does this just come into play when I try to build R from source, i.e. the folder where I would put the R tar.gz file? I always choose the paths C:\R\R-2.13.0\bin\i386\src (32 bit) and C:\R\R-2.13.0\bin\src (64 bit). Would this be okay? Thanks a lot for helping me out on this, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Reference Classes: shortcut like 'isS4' for Ref Classes?
Thanks for the answer! Sorry, must have missed that part of the help page. Your second approach is exactly what I was looking for. Regards, Janko On 06.06.2011 23:38, John Chambers wrote: As it says on the help page ?ReferenceClasses: All reference classes inherit from the class "envRefClass" So, is(x, "envRefClass") And, less well documented but less typing: is(x, "refClass") also works. On 6/6/11 9:48 AM, Janko Thyson wrote: Dear list, is there a shortcut-function to check whether a class is a Reference Class or not? There's something like this for S4 classes ('isS4(object)'), but I couldn't find anything regarding Ref Classes. Currently, I'm doing it this way, which is a bit clumsy: A <- setRefClass("A", fields=list(X="numeric")) a <- A$new() isRefClass <- function(object, ...){ return(getClass(class(object))@class == "refClassRepresentation") # getRefClass(class(object))@class == "refObjectGenerator" } isRefClass(a) [1] TRUE Regards, Janko __ 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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Reference Classes: shortcut like 'isS4' for Ref Classes?
Dear list, is there a shortcut-function to check whether a class is a Reference Class or not? There's something like this for S4 classes ('isS4(object)'), but I couldn't find anything regarding Ref Classes. Currently, I'm doing it this way, which is a bit clumsy: A <- setRefClass("A", fields=list(X="numeric")) a <- A$new() isRefClass <- function(object, ...){ return(getClass(class(object))@class == "refClassRepresentation") #getRefClass(class(object))@class == "refObjectGenerator" } isRefClass(a) [1] TRUE Regards, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Bug or feature: using "ANY" as a generic field class
Wow, that was fast! Thanks a lot! Regards, Janko On 06.06.2011 18:29, John Chambers wrote: > Should now behave as expected in r-devel and 2.13 patched, as of SVN > 56045, June 4. (noted in the NEWS file.) > > > On 6/6/11 6:27 AM, Janko Thyson wrote: >> Thanks a lot for your reply and I'm sorry if I didn't make it quite >> clear what I expected, but you got it right: >> >> I'd simply like to see the same behavior for Reference Classes as for S4 >> classes when extending classes with "ANY" fields as featured in the >> example below. >> >> > setClass("A", representation(x="ANY")) >> [1] "A" >> > setClass("B", contains="A", representation(x="character")) >> [1] "B" >> > new("B", x = "abc") >> An object of class "B" >> Slot "x": >> [1] "abc" >> >> Thanks for addressing this! >> >> Regards, >> Janko >> >> On 03.06.2011 19:13, John Chambers wrote: >>> Well, your mail is unclear as to what you expected, but there is one >>> bug shown by your example. >>> >>> The behavior of S4 classes is sensible, at least as far as the example >>> shows: >>> >>> >>> > setClass("A", representation(x="ANY")) >>> [1] "A" >>> > setClass("B", contains="A", representation(x="character")) >>> [1] "B" >>> > new("B", x=1:3) >>> Error in validObject(.Object) : >>> invalid class "B" object: invalid object for slot "x" in class "B": >>> got class "integer", should be or extend class "character" >>> >>> You couldn't expect the new() call to work, as the error message >>> clearly explains. A legitimate call does work: >>> >>> > new("B", x = "abc") >>> An object of class "B" >>> Slot "x": >>> [1] "abc" >>> >>> The reference classes should work the same way, but don't, as your >>> example shows. >>> >>> A <- setRefClass( >>> + Class="A", >>> + fields=list( >>> + .PRIMARYDATA="ANY" >>> + ), >>> + contains=c("VIRTUAL") >>> + ) >>> > B <- setRefClass( >>> + Class="B", >>> + fields=list( >>> + .PRIMARYDATA="character" >>> + ), >>> + contains=c("A") >>> + ) >>> Error in `insertFields<-`(`*tmp*`, value = "character") : >>> The overriding class("character") of field ".PRIMARYDATA" is not a >>> subclass of the existing field definition ("ANY") >>> >>> We'll fix that. And, yes, "ANY" is intended as a universal superclass, >>> but is usually not mentioned explicitly. >>> >>> >>> On 6/3/11 6:53 AM, Janko Thyson wrote: >>>> Dear list, >>>> >>>> I was wondering if you could help me out in clarifying something: >>>> Is it possible to use class "ANY" in slots/fields of formal classes >>>> if you >>>> a) do not want to restrict valid classes of that field and >>>> b) if you are making explicit use of class inheritance? >>>> >>>> It seems to work in simple scenarios but produces errors when class >>>> inheritance comes into play. So I was wondering if that's a feature >>>> or a >>>> bug. >>>> >>>> If using "ANY" is not the right way, I'd appreciate a pointer to >>>> how you >>>> can to this. >>>> >>>> See previous post with an example below. >>>> >>>> Regards, >>>> Janko >>>> >>>> On 06/03/2011 01:53 AM, Janko Thyson wrote: >>>>> On 31.05.2011 18:17, Martin Morgan wrote: >>>>>> On 05/30/2011 07:02 AM, Janko Thyson wrote: >>>>>>> Dear list, >>>>>>> >>>>>>> I would like to set one specific Reference Class field to be of an >>>>>>> arbitrary class. Is there a class that all R objects inherit >>>>>>> from? I >>>>>>> thought that "ANY" was something like this, but obviously that's >>>>>>> not >>
Re: [Rd] Bug or feature: using "ANY" as a generic field class (was: '[R] Is there a (virtual) class that all R objects inherit from?)
Thanks a lot for your reply and I'm sorry if I didn't make it quite clear what I expected, but you got it right: I'd simply like to see the same behavior for Reference Classes as for S4 classes when extending classes with "ANY" fields as featured in the example below. > setClass("A", representation(x="ANY")) [1] "A" > setClass("B", contains="A", representation(x="character")) [1] "B" > new("B", x = "abc") An object of class "B" Slot "x": [1] "abc" Thanks for addressing this! Regards, Janko On 03.06.2011 19:13, John Chambers wrote: Well, your mail is unclear as to what you expected, but there is one bug shown by your example. The behavior of S4 classes is sensible, at least as far as the example shows: > setClass("A", representation(x="ANY")) [1] "A" > setClass("B", contains="A", representation(x="character")) [1] "B" > new("B", x=1:3) Error in validObject(.Object) : invalid class "B" object: invalid object for slot "x" in class "B": got class "integer", should be or extend class "character" You couldn't expect the new() call to work, as the error message clearly explains. A legitimate call does work: > new("B", x = "abc") An object of class "B" Slot "x": [1] "abc" The reference classes should work the same way, but don't, as your example shows. A <- setRefClass( + Class="A", + fields=list( + .PRIMARYDATA="ANY" + ), + contains=c("VIRTUAL") + ) > B <- setRefClass( + Class="B", + fields=list( + .PRIMARYDATA="character" + ), + contains=c("A") + ) Error in `insertFields<-`(`*tmp*`, value = "character") : The overriding class("character") of field ".PRIMARYDATA" is not a subclass of the existing field definition ("ANY") We'll fix that. And, yes, "ANY" is intended as a universal superclass, but is usually not mentioned explicitly. On 6/3/11 6:53 AM, Janko Thyson wrote: Dear list, I was wondering if you could help me out in clarifying something: Is it possible to use class "ANY" in slots/fields of formal classes if you a) do not want to restrict valid classes of that field and b) if you are making explicit use of class inheritance? It seems to work in simple scenarios but produces errors when class inheritance comes into play. So I was wondering if that's a feature or a bug. If using "ANY" is not the right way, I'd appreciate a pointer to how you can to this. See previous post with an example below. Regards, Janko On 06/03/2011 01:53 AM, Janko Thyson wrote: On 31.05.2011 18:17, Martin Morgan wrote: On 05/30/2011 07:02 AM, Janko Thyson wrote: Dear list, I would like to set one specific Reference Class field to be of an arbitrary class. Is there a class that all R objects inherit from? I thought that "ANY" was something like this, but obviously that's not true: inherits(1:3, "ANY") [1] FALSE I can't speak to the implementation, but ANY functions as a base class in terms of slot / field assignment and inheritance, e.g., setClass("A", representation(x="ANY")) new("A", x=1:3) Martin Hi Martin, sorry for the late response. The way you do it works. Yet, when you declare dependencies more explicitly (contains=XY), then R complains. Is this a feature or a bug (with respect to the "less explicit" way working just fine)? See the example below: # S4 setClass("A", representation(x="ANY")) new("A", x=1:3) setClass("A", representation(x="ANY")) setClass("B", contains="A", representation(x="character")) new("B", x=1:3) # Reference Classes setRefClass( Class="A", fields=list( .PRIMARYDATA="ANY" ), contains=c("VIRTUAL") ) B<- setRefClass( Class="B", fields=list( .PRIMARYDATA="character" ), contains=c("A") ) Bug, I'd say. Martin Regards, Janko Regards, Janko [[alternative HTML version deleted]] __ r-h...@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-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
[Rd] Bug or feature: using "ANY" as a generic field class (was: '[R] Is there a (virtual) class that all R objects inherit from?)
Dear list, I was wondering if you could help me out in clarifying something: Is it possible to use class "ANY" in slots/fields of formal classes if you a) do not want to restrict valid classes of that field and b) if you are making explicit use of class inheritance? It seems to work in simple scenarios but produces errors when class inheritance comes into play. So I was wondering if that's a feature or a bug. If using "ANY" is not the right way, I'd appreciate a pointer to how you can to this. See previous post with an example below. Regards, Janko On 06/03/2011 01:53 AM, Janko Thyson wrote: > On 31.05.2011 18:17, Martin Morgan wrote: >> On 05/30/2011 07:02 AM, Janko Thyson wrote: >>> Dear list, >>> >>> I would like to set one specific Reference Class field to be of an >>> arbitrary class. Is there a class that all R objects inherit from? I >>> thought that "ANY" was something like this, but obviously that's not >>> true: >>> >>> > inherits(1:3, "ANY") >>> [1] FALSE >> >> I can't speak to the implementation, but ANY functions as a base class >> in terms of slot / field assignment and inheritance, e.g., >> >> setClass("A", representation(x="ANY")) >> new("A", x=1:3) >> >> Martin > > Hi Martin, > > sorry for the late response. The way you do it works. Yet, when you > declare dependencies more explicitly (contains=XY), then R complains. Is > this a feature or a bug (with respect to the "less explicit" way working > just fine)? See the example below: > > # S4 > setClass("A", representation(x="ANY")) > new("A", x=1:3) > > setClass("A", representation(x="ANY")) > setClass("B", contains="A", representation(x="character")) > new("B", x=1:3) > > # Reference Classes > setRefClass( > Class="A", > fields=list( > .PRIMARYDATA="ANY" > ), > contains=c("VIRTUAL") > ) > B <- setRefClass( > Class="B", > fields=list( > .PRIMARYDATA="character" > ), > contains=c("A") > ) Bug, I'd say. Martin > > Regards, > Janko >>> >>> Regards, >>> Janko >>> >>> [[alternative HTML version deleted]] >>> >>> __ >>> r-h...@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. >> >> -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Query super- and subclasses of a class: is there a better way than to use 'completeClassDefinition()'
Hi Martin, right, that's exactly what I thought. Thanks for the pointer to 'getClassDef()'. Pretty obvious place to start, I have to admit ;-) But I had this 'completeClassDefinition()' thing in a function I've written long long ago where I didn't really know my way around class details yet. Thanks, Janko On 31.05.2011 18:15, Martin Morgan wrote: > On 05/30/2011 08:54 AM, Janko Thyson wrote: >> Dear List, >> >> when I first started to use S4 classes, I used the function >> 'completeClassDef()' in order to see the super- and subclasses of a >> certain class: > > Hi Janko -- I think 'complete' is meant as an adverb here; what you > might want is names(getClassDef("A")@subclasses) (see > slotNames(class(getClassDef("A"))) for other useful info). > > Martin > >> >> setClass(Class="A", representation=list(a="numeric")) >> setClass(Class="B", contains="A", representation=list(b="character")) >> # Super >> x<- completeClassDefinition("B") >> attributes(x) >> names(x@contains) >> # Sub >> x<- completeClassDefinition("A") >> attributes(x) >> names(x@subclasses) >> >> This also does the trick for Reference Classes for me. However, I >> re-read the respective section on the help page and wondered if I should >> be more careful about using this function for this purpose as the >> page says: >> "|completeClassDefinition: |Completes the definition of |Class|, >> relative to the class definitions visible from environment |where|. If >> |doExtends| is |TRUE|, complete the super- and sub-class information. >> This function is called when a class is defined or re-defined." >> >> So here are my questions: >> 1) Is it safe to call 'completeClassDef()' explicitly or can anything be >> "overwritten" by this? >> 2) Is there a better way to query the super-/subclasses of a certain >> S4/Reference Class? >> >> Best regards and I'd like to take this opportunity to express my >> gratitude to everyone on this list who takes the time to provide such >> great help! >> Janko >> >> >> >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > > -- *Janko Thyson* janko.thy...@googlemail.com <mailto:janko.thy...@googlemail.com> Jesuitenstraße 3 D-85049 Ingolstadt Mobile: +49 (0)176 83294257 This e-mail and any attachment is for authorized use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Query super- and subclasses of a class: is there a better way than to use 'completeClassDefinition()'
Dear List, when I first started to use S4 classes, I used the function 'completeClassDef()' in order to see the super- and subclasses of a certain class: setClass(Class="A", representation=list(a="numeric")) setClass(Class="B", contains="A", representation=list(b="character")) # Super x <- completeClassDefinition("B") attributes(x) names(x@contains) # Sub x <- completeClassDefinition("A") attributes(x) names(x@subclasses) This also does the trick for Reference Classes for me. However, I re-read the respective section on the help page and wondered if I should be more careful about using this function for this purpose as the page says: "|completeClassDefinition: |Completes the definition of |Class|, relative to the class definitions visible from environment |where|. If |doExtends| is |TRUE|, complete the super- and sub-class information. This function is called when a class is defined or re-defined." So here are my questions: 1) Is it safe to call 'completeClassDef()' explicitly or can anything be "overwritten" by this? 2) Is there a better way to query the super-/subclasses of a certain S4/Reference Class? Best regards and I'd like to take this opportunity to express my gratitude to everyone on this list who takes the time to provide such great help! Janko -- *Janko Thyson* janko.thy...@googlemail.com <mailto:janko.thy...@googlemail.com> Jesuitenstraße 3 D-85049 Ingolstadt Mobile: +49 (0)176 83294257 This e-mail and any attachment is for authorized use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Reference Classes/S4 Classes: can method dispatch check superclasses BEFORE resorting to method for "ANY"?
Cool, thanks a lot for the insight! I forgot that there is the option to use 'contains="VIRTUAL" and probably out of laziness usually set my virtual S4 classes simply via 'setClass("Something")'. On 27.05.2011 15:22, Martin Morgan wrote: > On 05/27/2011 06:13 AM, Janko Thyson wrote: >> Dear list, >> >> is it possible that method dispatch checks for superclasses/virtual >> classes before checking "ANY"? >> >> I'd like to build a generic initialization method for all my Reference >> Class (say "MyDataFrame") objects by having them inherit from class, say >> "MyRefClassVirtual" (which would have to be a virtual S4 class; there >> are no virtual Reference Classes, are there?) > > Reference classes can be virtual; 'initialize' is a reference method, > not an S4 method. > > .A <- setRefClass("A", contains="VIRTUAL", > methods=list( > initialize=function(..., msg="initialize,AA") { > callSuper(...) > message(msg) > .self > })) > .AA <- setRefClass("AA", contains="A") > > > .A$new() > Error in methods::new(def, ...) : > trying to generate an object from a virtual class ("A") > > .AA$new() > initialize,AA > An object of class "AA" > > > Martin > >> The problem is that 'getRefClass("MyDataFrame")$new' calls (I think) the >> method that was written for "ANY". Thus even though I write a explicit >> initialize method for class "MyRefClassVirtual" which I should be called >> for "MyDataFrame" as it inherits from this class, this method will never >> be called because "ANY beats anything else". >> >> So, I think I'd like to tell the method somehow to check for >> superclass/virtual classes *before* resorting to "ANY". >> >> Is that possible? >> >> Regards, >> Janko >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > > -- *Janko Thyson* janko.thy...@googlemail.com <mailto:janko.thy...@googlemail.com> Jesuitenstraße 3 D-85049 Ingolstadt Mobile: +49 (0)176 83294257 This e-mail and any attachment is for authorized use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Reference Classes/S4 Classes: can method dispatch check superclasses BEFORE resorting to method for "ANY"?
Dear list, is it possible that method dispatch checks for superclasses/virtual classes before checking "ANY"? I'd like to build a generic initialization method for all my Reference Class (say "MyDataFrame") objects by having them inherit from class, say "MyRefClassVirtual" (which would have to be a virtual S4 class; there are no virtual Reference Classes, are there?) The problem is that 'getRefClass("MyDataFrame")$new' calls (I think) the method that was written for "ANY". Thus even though I write a explicit initialize method for class "MyRefClassVirtual" which I should be called for "MyDataFrame" as it inherits from this class, this method will never be called because "ANY beats anything else". So, I think I'd like to tell the method somehow to check for superclass/virtual classes *before* resorting to "ANY". Is that possible? Regards, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Reference Classes: strange behavior when trying to change class def in the same R session
Dear list, I'm getting some strange behavior with Reference Classes every once in a while and I can't really put my finger on the cause. It'd be great if someone using Reference Classes could check if he/she experiences similar problems: The thing is that when I alter the definition of a Reference Class in a running R session and source the respective file containing the class def, sometimes the changes are reflected and sometimes not. I also tried to explicitly remove the class via 'removeClass()', and that too works at times and then again it doesn't. If it doesn't work it means that I have to shut down the session and start a new one, which is quite bothersome. I thought that it maybe had something to do with whether an explicit 'initialize' method has been defined or not, but the "bug" was still erratic. Here's some code that you can test it with: # S4 Classes setClass(Class="Horst", representation=list(a="numeric")) horst <- new("Horst", a=5) horst removeClass("Horst") horst <- new("Horst") setClass(Class="Horst", representation=list(a="character")) horst <- new("Horst", a="blabla") horst # Reference Classes setRefClass(Class="Horst", fields=list(a="numeric"), methods=list( foo=function() print("hello world!"))) setMethod( f="initialize", signature=signature(.Object="Horst"), definition=function( .Object ){ return(.Object) } ) gen <- getRefClass("Horst") horst <- gen$new() horst$a horst$a <- 5 horst$a horst$foo() removeClass("Horst") setRefClass(Class="Horst", fields=list(a="character"), methods=list( foo=function(x) print(x))) gen <- getRefClass("Horst") horst <- gen$new() horst$a horst$a <- 5 horst$a horst$foo(x=5) Most of the times the change from the first to the second config of ref class "Horst" produced a problem and required a 'removeClass()'. Strangely, going from the second config back to the first usually works without 'removeClass()'. Thanks in advance for taking the time to play this through, Janko R version 2.13.0 (2011-04-13) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] LC_TIME=German_Germany.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] codetools_0.2-8 tools_2.13.0 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Reference Classes: getter and setter functions/methods and possible shortcuts
Hi everyone, just wanted to ask what's the smartest/recommended way of defining getter and setter function *shortcuts* (i.e. something like "[", "[<-") for Reference Class objects? Or is it desired to not use this stuff, but define methods like 'obj$getSubset(row=1:3, col=1)' and 'obj$setSubset(value=x)' instead? I have some example code that might help in clarifying what I'm exactly after: setRefClass( Class="MyDataFrame", fields=list( PRIMARYDATA="data.frame" ), methods=list( "subsetGet"=function( idx.row, idx.col, drop=if(missing(idx.row)) TRUE else length(PRIMARYDATA) == 1, ... ){ PRIMARYDATA[idx.row, idx.col, drop=drop] } ) ) setMethod( f="initialize", signature=signature(.Object="MyDataFrame"), definition=function( .Object, ..., row.names=NULL, check.rows=FALSE, check.names=TRUE, stringsAsFactors=default.stringsAsFactors() ){ x.primarydata <- data.frame(..., row.names=row.names, check.rows=check.rows, check.names=check.names, stringsAsFactors=stringsAsFactors) x.generator <- getRefClass(class(.Object)) x.generator$accessors(names(x.generator$fields())) .Object$PRIMARYDATA <- x.primarydata return(.Object) } ) myDataFrameCreate <- function( ..., row.names=NULL, check.rows=FALSE, check.names=TRUE, stringsAsFactors=default.stringsAsFactors(), .class.name="MyDataFrame" ){ out <- getRefClass(.class.name)$new( ..., row.names=row.names, check.rows=check.rows, check.names=check.names, stringsAsFactors=stringsAsFactors ) return(out) } "[.MyDataFrame" <- function( src, idx.row, idx.col, drop=if(missing(idx.row)) TRUE else length(src$PRIMARYDATA) == 1, ... ){ if(!inherits(src, "MyDataFrame")){ stop("Expecting 'src' to be of class 'MyDataFrame") } return(src$PRIMARYDATA[idx.row, idx.col, drop=drop]) } mdf <- myDataFrameCreate(a=1:5, b=1:5) mdf mdf$PRIMARYDATA mdf$getPRIMARYDATA() # automaticall set via 'getRefClass("MyDataFrame")$accessors()' mdf$subsetGet(1,1) mdf$subsetGet(1,) mdf$subsetGet(,1) mdf$subsetGet(,1,drop=FALSE) mdf[1,1] mdf[1,] mdf[,1] mdf[,1, drop=FALSE] Thanks a lot for any advice, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Is it possible to define a function's arguments via a wildcard in 'substitute()'?
Thanks a lot Hadley, think I got it figured out now. expr <- substitute( myFoo <- function( myArg=0 ){ print("hello world!") eval(BODY) if("..." %in% names(formals(as.character(sys.call())[1]))){ print(data.frame(...)) } else { print("extended arguments not available yet.") } }, list(BODY=x.body) ) eval(expr) myFoo() myFoo(myArg=100) formals(myFoo) formals(myFoo) <- c(formals(myFoo), formals(data.frame)) formals(myFoo) myFoo() myFoo(myArg=100) myFoo(a=1:5, b=1:5, myArg=100) eval(call("myFoo", a=1:5, b=1:5)) do.call("myFoo", args=list(a=1:5, b=1:5)) One more question: is it possible to "augment" a function's body as I did with the function's arguments? If there'd be a method that coerces objects of class "list" to class "{" and 'body()' would allow assignments of that class, you could run something like: body(myFoo) <- as.curlyBracket(append(as.list(body(myFoo)), list(expression(eval(print("blabla")) But I guess there isn't. Enough with playing around ;-) Thanks, Janko On 26.05.2011 18:08, Hadley Wickham wrote: > I think for the case where you want to built up a call from a function > name + list of arguments, it's best to use call or as.call: > > call("f", a = 1, b = 2, c = 3) > > or if you already have the list: > l<- list(as.name("f"), a = 1, b = 2, c = 3) > as.call(l) > > Hadley > > On Thu, May 26, 2011 at 10:15 AM, Janko Thyson > wrote: >> Dear List, >> >> just out of pure curiosity: is it possible to define a function via >> 'substitute()' such that the function's formal arguments are specified by a >> "wildcard" that is substituted when the expression is evaluated? >> >> Simple example: >> >> x.args<- formals("data.frame") >> x.body<- expression( >> out<- myArg + 100, >> return(out) >> ) >> >> expr<- substitute( >> myFoo<- function( >> ARGS, >> myArg >> ){ >> print("hello world!") >> print(ARGS) >> eval(BODY) >> >> }, >> list(ARGS=x.args, BODY=x.body) >> ) >> >> eval(expr) >> myFoo(myArg=5) >> # works >> >> myFoo(a=1:3, stringsAsFactors=FALSE, myArg=5) >> # does not work >> >> It works for wildcard 'BODY' in the function's body, but not for wildcard >> 'ARGS' in the argument definition part of the function definition. >> >> I thought that when writing a function that depends on some other function >> like 'data.frame()', it would maybe be possible not to 'hardcode' the formal >> arguments of 'data.frame()' in the new function def but to have it mapped >> somewhat dynamically so that when 'data.frame()' changes, the new function >> would change as well. This is probably a bad idea for countless reasons, >> nevertheless I'd be interested in learning if it's possible at all ;-) >> >> TIA, >> Janko >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> > > -- *Janko Thyson* janko.thy...@googlemail.com <mailto:janko.thy...@googlemail.com> Jesuitenstraße 3 D-85049 Ingolstadt Mobile: +49 (0)176 83294257 This e-mail and any attachment is for authorized use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Is it possible to define a function's arguments via a wildcard in 'substitute()'?
Dear List, just out of pure curiosity: is it possible to define a function via 'substitute()' such that the function's formal arguments are specified by a "wildcard" that is substituted when the expression is evaluated? Simple example: x.args <- formals("data.frame") x.body <- expression( out <- myArg + 100, return(out) ) expr <- substitute( myFoo <- function( ARGS, myArg ){ print("hello world!") print(ARGS) eval(BODY) }, list(ARGS=x.args, BODY=x.body) ) eval(expr) myFoo(myArg=5) # works myFoo(a=1:3, stringsAsFactors=FALSE, myArg=5) # does not work It works for wildcard 'BODY' in the function's body, but not for wildcard 'ARGS' in the argument definition part of the function definition. I thought that when writing a function that depends on some other function like 'data.frame()', it would maybe be possible not to 'hardcode' the formal arguments of 'data.frame()' in the new function def but to have it mapped somewhat dynamically so that when 'data.frame()' changes, the new function would change as well. This is probably a bad idea for countless reasons, nevertheless I'd be interested in learning if it's possible at all ;-) TIA, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Feature request: extend functionality of 'unlist()' by args 'delim=c("/", "_", etc.)' and 'keep.special=TRUE/FALSE'
On 19.05.2011 14:58, Duncan Murdoch wrote: > On 19/05/2011 8:15 AM, Janko Thyson wrote: >> Dear list, >> >> I hope this is the right place to post a feature request. If there's >> exists a more formal channel (e.g. as for bug reports), I'd appreciate a >> pointer. > > This is a good place to post. > >> >> I work a lot with named nested lists with arbitrary degrees of >> "nestedness". In order to retrieve the names and/or values of "bottom >> layer/bottom tier", I love the functionality of 'unlist()', or >> 'names(unlist(x))', respectively as it avoids traversing the nested >> lists via recursive loop constructs. I'm also aware that the general >> suggestion is probably to keep nestedness as low as possible when >> working with lists, but arbitrary deeply nested lists came in quite >> handy for me as long as each element is named and as long as I can >> quickly add and retrieve element values via "name paths". >> >> Here's a little example list: >> lst<- list(a=list(a.1=list(a.1.1=NA, a.1.2=5), a.2=list()), b=NULL) >> >> It would be awesome if 'unlist(x)' could be extended with the following >> functionality: >> >> 1) An argument such as 'delim' that controls how the respective layer >> names are pasted. >> Right now, they are always separated by a dot: >> > names(unlist(lst)) >> [1] "a.a.1.a.1.1" "a.a.1.a.1.2" >> Desired: >> > names(unlist(lst, delim="/")) >> [1] "a/a.1/a.1.1" "a/a.1/a.1.2" >> > names(unlist(lst, delim="_")) >> [1] "a_a.1_a.1.1" "a_a.1_a.1.2" >> >> 2) An argument that allows to include either elements of zero length or >> of value NULL to be *included* in the resulting output. >> Right now, they are dropped (which makes perfect sense as NULL values >> and zero length values are dropped in vectors): >> > c(1,2, NULL, numeric()) >> [1] 1 2 >> > unlist(lst) >> a.a.1.a.1.1 a.a.1.a.1.2 >>NA 5 >> Desired: >> > unlist(lst, delim="/", keep.special=TRUE) >> $a/a.1/a.1.1 >> [1] NA >> >> $a/a.1/a.1.2 >> [1] 5 >> >> $a/a.2 >> list() >> >> $b >> NULL >> Of course, this would not be a true 'unlist' anymore, but something like >> 'retrieveBottomLayer()'. >> >> Thanks a lot for providing such fast stuff as 'unlist()'! Unfortunately, >> I don't know my way around internal C routines and therefore I would >> greatly appreciate if core team developers would consider my two >> suggestions. > > The suggestions seem reasonable, but are difficult to implement. The > problem is that unlist() is a generic function, but there's no > unlist.default() in R: the default and method dispatch are > implemented at the C level. Normally adding arguments to the default > method doesn't cause problems elsewhere, because methods only need to > be compatible with the generic. But since there's no way to modify > the argument list of the default method in this case, the generic > function would need to be modified, and that means every unlist method > would need to be modified too. > > So I wouldn't want to take this on. Just one more question regarding this: would it then maybe possible to take the existing generic function 'unlist()', modify it and introduce it as a new function, say 'flatten()' for which methods exist for environments and lists?. That way you would not have to touch existing methods for 'unlist()'. Or is the introduction of new base functions discouraged in order to keep things manageable? Thanks again! > > In case someone else does, I'd suggest a different change than the > "keep.special" argument. I think a "coerce=TRUE" argument would be > better: If TRUE, you get the current behaviour, which coerces > components according to the hierarchy listed on the help page. If > FALSE, then no coercion is done, and unlist() just flattens the list > into a new one, e.g. > > unlist( list(1, 2, NULL, list("A", "B")), coerce=FALSE) > > would return list(1, 2, NULL, "A", "B") instead of c("1", "2", "A", "B"). > > One workaround I thought of was to add an element to the list that > couldn't be coerced, but this doesn't work. For example: > > e <- environment() # can't be coerced > x <- list
Re: [Rd] Feature request: extend functionality of 'unlist()' by args 'delim=c("/", "_", etc.)' and 'keep.special=TRUE/FALSE'
On 19.05.2011 14:58, Duncan Murdoch wrote: > On 19/05/2011 8:15 AM, Janko Thyson wrote: >> Dear list, >> >> I hope this is the right place to post a feature request. If there's >> exists a more formal channel (e.g. as for bug reports), I'd appreciate a >> pointer. > > This is a good place to post. > >> >> I work a lot with named nested lists with arbitrary degrees of >> "nestedness". In order to retrieve the names and/or values of "bottom >> layer/bottom tier", I love the functionality of 'unlist()', or >> 'names(unlist(x))', respectively as it avoids traversing the nested >> lists via recursive loop constructs. I'm also aware that the general >> suggestion is probably to keep nestedness as low as possible when >> working with lists, but arbitrary deeply nested lists came in quite >> handy for me as long as each element is named and as long as I can >> quickly add and retrieve element values via "name paths". >> >> Here's a little example list: >> lst<- list(a=list(a.1=list(a.1.1=NA, a.1.2=5), a.2=list()), b=NULL) >> >> It would be awesome if 'unlist(x)' could be extended with the following >> functionality: >> >> 1) An argument such as 'delim' that controls how the respective layer >> names are pasted. >> Right now, they are always separated by a dot: >> > names(unlist(lst)) >> [1] "a.a.1.a.1.1" "a.a.1.a.1.2" >> Desired: >> > names(unlist(lst, delim="/")) >> [1] "a/a.1/a.1.1" "a/a.1/a.1.2" >> > names(unlist(lst, delim="_")) >> [1] "a_a.1_a.1.1" "a_a.1_a.1.2" >> >> 2) An argument that allows to include either elements of zero length or >> of value NULL to be *included* in the resulting output. >> Right now, they are dropped (which makes perfect sense as NULL values >> and zero length values are dropped in vectors): >> > c(1,2, NULL, numeric()) >> [1] 1 2 >> > unlist(lst) >> a.a.1.a.1.1 a.a.1.a.1.2 >>NA 5 >> Desired: >> > unlist(lst, delim="/", keep.special=TRUE) >> $a/a.1/a.1.1 >> [1] NA >> >> $a/a.1/a.1.2 >> [1] 5 >> >> $a/a.2 >> list() >> >> $b >> NULL >> Of course, this would not be a true 'unlist' anymore, but something like >> 'retrieveBottomLayer()'. >> >> Thanks a lot for providing such fast stuff as 'unlist()'! Unfortunately, >> I don't know my way around internal C routines and therefore I would >> greatly appreciate if core team developers would consider my two >> suggestions. > > The suggestions seem reasonable, but are difficult to implement. The > problem is that unlist() is a generic function, but there's no > unlist.default() in R: the default and method dispatch are > implemented at the C level. Normally adding arguments to the default > method doesn't cause problems elsewhere, because methods only need to > be compatible with the generic. But since there's no way to modify > the argument list of the default method in this case, the generic > function would need to be modified, and that means every unlist method > would need to be modified too. > > So I wouldn't want to take this on. Okay, get it. Thanks for the insight. > > In case someone else does, I'd suggest a different change than the > "keep.special" argument. I think a "coerce=TRUE" argument would be > better: If TRUE, you get the current behaviour, which coerces > components according to the hierarchy listed on the help page. If > FALSE, then no coercion is done, and unlist() just flattens the list > into a new one, e.g. > > unlist( list(1, 2, NULL, list("A", "B")), coerce=FALSE) > > would return list(1, 2, NULL, "A", "B") instead of c("1", "2", "A", "B"). > > One workaround I thought of was to add an element to the list that > couldn't be coerced, but this doesn't work. For example: > > e <- environment() # can't be coerced > x <- list(1, 2, NULL, list("A", "B"), e) > unlist(x) > > # Returns list(1,2,"A","B",e) > > I think it would be reasonable for this version to retain the NULL, > since it is not doing any coercion. Thanks for taking the time to address this. A function that also seemed pretty fast to me with respect to retrieving list structures is '
[Rd] Feature request: extend functionality of 'unlist()' by args 'delim=c("/", "_", etc.)' and 'keep.special=TRUE/FALSE'
Dear list, I hope this is the right place to post a feature request. If there's exists a more formal channel (e.g. as for bug reports), I'd appreciate a pointer. I work a lot with named nested lists with arbitrary degrees of "nestedness". In order to retrieve the names and/or values of "bottom layer/bottom tier", I love the functionality of 'unlist()', or 'names(unlist(x))', respectively as it avoids traversing the nested lists via recursive loop constructs. I'm also aware that the general suggestion is probably to keep nestedness as low as possible when working with lists, but arbitrary deeply nested lists came in quite handy for me as long as each element is named and as long as I can quickly add and retrieve element values via "name paths". Here's a little example list: lst <- list(a=list(a.1=list(a.1.1=NA, a.1.2=5), a.2=list()), b=NULL) It would be awesome if 'unlist(x)' could be extended with the following functionality: 1) An argument such as 'delim' that controls how the respective layer names are pasted. Right now, they are always separated by a dot: > names(unlist(lst)) [1] "a.a.1.a.1.1" "a.a.1.a.1.2" Desired: > names(unlist(lst, delim="/")) [1] "a/a.1/a.1.1" "a/a.1/a.1.2" > names(unlist(lst, delim="_")) [1] "a_a.1_a.1.1" "a_a.1_a.1.2" 2) An argument that allows to include either elements of zero length or of value NULL to be *included* in the resulting output. Right now, they are dropped (which makes perfect sense as NULL values and zero length values are dropped in vectors): > c(1,2, NULL, numeric()) [1] 1 2 > unlist(lst) a.a.1.a.1.1 a.a.1.a.1.2 NA 5 Desired: > unlist(lst, delim="/", keep.special=TRUE) $a/a.1/a.1.1 [1] NA $a/a.1/a.1.2 [1] 5 $a/a.2 list() $b NULL Of course, this would not be a true 'unlist' anymore, but something like 'retrieveBottomLayer()'. Thanks a lot for providing such fast stuff as 'unlist()'! Unfortunately, I don't know my way around internal C routines and therefore I would greatly appreciate if core team developers would consider my two suggestions. Best regards, Janko -- *Janko Thyson* janko.thy...@ku-eichstaett.de <mailto:janko.thy...@ku-eichstaett.de> Catholic University of Eichstätt-Ingolstadt Ingolstadt School of Management Statistics and Quantitative Methods Auf der Schanz 49 D-85049 Ingolstadt www.wfi.edu/lsqm <http://www.wfi.edu/lsqm> Fon: +49 841 937-1923 Fax: +49 841 937-1965 This e-mail and any attachment is for authorized use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. -- *Janko Thyson* janko.thy...@googlemail.com <mailto:janko.thy...@googlemail.com> Jesuitenstraße 3 D-85049 Ingolstadt Mobile: +49 (0)176 83294257 This e-mail and any attachment is for authorized use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Reference Classes: replacing '.self' with an .Rda image of '.self' from within a method? (was replacing '.self' with an .Rda image of '.self' from within a method?)
Sorry guys, but I chose a really stupid name before (no "reference classes"). Hope it's okay to re-post. Cheers, Janko >>> ORIGINAL MESSAGE <<< Dear list, Is it possible to update or reassign '.self' with an image of '.self' (e.g. a locally stored .Rda file) from within a method? I know that this might sound akward, but here's the use case: 1) Ref Class Definition setRefClass(Class="Test", fields=list(A="character", B="character"), methods=list(importImage=function(path){ variable <- load(path) expr <- paste("assign('", variable, "',", variable, ", envir=.self)", sep="") eval(parse(text=expr)) } ) 2) Initialize Method Definition setMethod( f="initialize", signature=signature(.Object="Test"), definition=function( .Object, path=NULL ){ obj <- callNextMethod(.Object) if(!is.null(path){ obj$importImage(path=path) } return(obj) } 3) Intended and "Extended" Use Method 'importImage' was originally intended to read either an object of name 'A' or 'B' from a respective path and overwrite the respective fields in an obj of class 'Test'. Now I wondered how I could "reassign"/update the object of class 'Test' itself by reading a respective .Rda image of an object of class 'Test' from within 'obj$importImage()'. The way I've written 'importImage()', it did not work. Yet I wonder if it's possible. 4) My Workaround (but I'm looking for something more elegantly) In the class definition: [...] methods=list(importImage=function(path){ variable <- load(path) if(variable != ".self"){ expr <- paste("assign('", variable, "',", variable, ", envir=.self)", sep="") eval(parse(text=expr)) return(TRUE) } else { return(.self) } }) [...] In the initialize method: setMethod( f="initialize", signature=signature(.Object="Test"), definition=function( .Object, path=NULL ){ obj <- callNextMethod(.Object) if(!is.null(path){ rslt <- obj$importImage(path=path) if(!is.logical(rslt)){ obj <- rslt } } return(obj) } Thanks for any comments, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Replacing '.self' with an .Rda image of '.self' from within a method?
Dear list, Is it possible to update or reassign '.self' with an image of '.self' (e.g. a locally stored .Rda file) from within a method? I know that this might sound akward, but here's the use case: 1) Ref Class Definition setRefClass(Class="Test", fields=list(A="character", B="character"), methods=list(importImage=function(path){ variable <- load(path) expr <- paste("assign('", variable, "',", variable, ", envir=.self)", sep="") eval(parse(text=expr)) } ) 2) Initialize Method Definition setMethod( f="initialize", signature=signature(.Object="Test"), definition=function( .Object, path=NULL ){ obj <- callNextMethod(.Object) if(!is.null(path){ obj$importImage(path=path) } return(obj) } 3) Intended and "Extended" Use Method 'importImage' was originally intended to read either an object of name 'A' or 'B' from a respective path and overwrite the respective fields in an obj of class 'Test'. Now I wondered how I could "reassign"/update the object of class 'Test' itself by reading a respective .Rda image of an object of class 'Test' from within 'obj$importImage()'. The way I've written 'importImage()', it did not work. Yet I wonder if it's possible. 4) My Workaround (but I'm looking for something more elegantly) In the class definition: [...] methods=list(importImage=function(path){ variable <- load(path) if(variable != ".self"){ expr <- paste("assign('", variable, "',", variable, ", envir=.self)", sep="") eval(parse(text=expr)) return(TRUE) } else { return(.self) } }) [...] In the initialize method: setMethod( f="initialize", signature=signature(.Object="Test"), definition=function( .Object, path=NULL ){ obj <- callNextMethod(.Object) if(!is.null(path){ rslt <- obj$importImage(path=path) if(!is.logical(rslt)){ obj <- rslt } } return(obj) } Thanks for any comments, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Possible bug in 'relist()' and/or 'as.relistable()'
Dear list, I think I just stumbled across a bug in either 'relist()' and/or 'as.relistable()'. It seems that 'pairlists' can only be un- and relisted as long as they're not nested: Good: a <- as.relistable(as.pairlist(list(a=1, b=2))) a <- unlist(a) relist(a)# Works Bad: a <- as.relistable(as.pairlist(list(a=1, b=2, c=list(c.1=1, c.2=2 a <- unlist(a) relist(a) The help page didn't say anything about pairlists and I don't know if they're at all relevant, but I'm using them whenever I want my functions to recognize a clear 'name-value' structure (e.g. for batch assigning variables) as opposed to standard list structures. Cheers, Janko > sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] LC_TIME=German_Germany.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] codetools_0.2-8 tools_2.12.1 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Run script automatically when package is loaded
Dear list, is it possible to specify a script that is executed "automatically" when my package is mounted via 'require(my.pkg)' or 'library(my.pkg)'? Id' like to specify execute a small init function that creates some crucial environment structures. As it's always the first thing to do when using the package, I wanted to "hide" it from the user so he won't have to think about this step. Can I use the lazy-loading functionality of packages for that (Writing R Extensions, Section 1.1.5 Data in packages, pp. 10)? Thanks for any suggestions, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Reference classes: error with missing arguments in method calls
Dear list, I'm having problems in understanding an error that pops up in the context of missing arguments with methods of reference class objects. Because of the following statement taken from '?referenceClass', my ref class methods call explicit S4 methods: "Reference methods should be kept simple; if they need to do some specialized R computation, that computation should use a separate R function that is called from the reference method" So a ref class would look like this: setRefClass(Class="Xmple", methods=list(foo=function(var.1, ...) fooMthd(.self=.self, var.1=var.1, ...))) I'd like to keep the generics defs as simple as possible, thus their only arg should be '.self'. The S4 methods are specified in a way that if 'var.1' is missing, it will be assigned some default value (I know I could explicitly set the default value, yet I would like to rely on 'missing()' for that). Now, my problem is that this works fine if the generic contains an argument 'var.1', but results in an error if it doesn't. And I don't quite understand why since it seems to be related to whether the S4 method is invoked from a call to a ref class method or not. Here's an example which demonstrates when it works as planed and when the error occurs. I tried to keep as short as possible: # 1) "Stand-alone" context setGeneric(name="fooMthd", def=function(.self, ...) standardGeneric("fooMthd"), signature=c(".self")) setMethod(f="fooMthd", signature=signature(.self="character"), definition=function(.self, var.1, ...){ cat("I'm having one additional argument compared to my generic:", sep="\n") if(missing(var.1)) var.1 <- "some default value" cat(paste("* var.1: ", var.1, sep=""), sep="\n") }) fooMthd(.self="blabla", var.1="hello world!") fooMthd(.self="blabla") # Works. #+ # 2) Reference class context setMethod(f="fooMthd", signature=signature(.self="Xmple"), definition=function(.self, var.1, ...){ cat("I'm having one additional argument compared to my generic:", sep="\n") if(missing(var.1)) var.1 <- "some default value" cat(paste("* var.1: ", var.1, sep=""), sep="\n") }) setRefClass(Class="Xmple", methods=list(foo=function(var.1, ...) fooMthd(.self=.self, var.1=var.1, ...))) xmple <- getRefClass(Class="Xmple")$new() xmple$foo(var.1="hallo") xmple$foo() # Does not work. #+ # 3) "Fixed generic" context setGeneric(name="fooMthd", def=function(.self, var.1, ...) standardGeneric("fooMthd"), signature=c(".self")) setMethod(f="fooMthd", signature=signature(.self="Xmple"), definition=function(.self, var.1, ...){ cat("I'm having one additional argument compared to my generic:", sep="\n") if(missing(var.1)) var.1 <- "some default value" cat(paste("* var.1: ", var.1, sep=""), sep="\n") }) xmple$foo(var.1=" blabla") xmple$foo() # Works. I do understand that in the ref class 'foo()' has trouble passing an arg to 'fooMthd()' that hasn't been specified. But why and how does simply including 'var.1' in the generic def fix this? Thanks for any comments, Janko R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] LC_TIME=German_Germany.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] codetools_0.2-6 tools_2.12.1 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Avoiding name clashes: opinion on best practice naming conventions
Dear List, I'm trying to figure out some best practice way with respect to the naming conventions when building own packages. I'd like to minimize the risk of choosing function names that might interfere with those of other packages (both available ones and those yet to come). I came up with following alternatives 1. Prefixing the actual names (e.g. myPkgfoo() instead of foo()): pretty verbose 2. Emulating a package namespace while developing and explicitly using myPkg::foo() in all scripts: IMHO the best way, but apparently not possible as I learned. 3. Carefully choosing which functions to export. Yet, I'm not sure I completely understand the implications of exported functions. Does this imply that not exported functions cannot interfere with functions in other namespaces? I'd be great to hear some recommendations on this one! Thanks a lot, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Error handling with frozen RCurl function calls + Identification of frozen R processes
Dear list, I'm tackling an empiric research problem that requires me to address a whole bunch of conceptual and/or technical details at the same time which cuts time short for all the nitty-gritty details of the "components" involved. Having said this, I'm lacking the time at the moment to deeply dive into parallel computing and HTTP requests via RCurl and I hope you can help me out with one or two imminent issues of my crawler/scraper: Once a day, I'm running 'RCurl::getURIAsynchronous(x=URL.frontier.sub, multiHandle=my.multi.handle)' within an lapply()-construct in order to read chunks of deterministically composed URLs from a host. There are courtesy time delays implemented between the individual http requests (5 times the time the last request from this host took) so that I'm not clogging the host. I'm causing about 15 minutes of traffic per day. The problem is, that 'getURIAsynchronous()' simply freezes sometimes and I don't have a clue why so. I also can't reproduce the error as it's totally erratic. I tried to put the function inside a try() or tryCatch() construct to no avail. Also, I've experimented with a couple of timeout options of Curl, but honestly didn't really understand all the implications. None worked so far. It simply seems that upon an error 'getURIAsynchronous()' simply does not give control back to the R process. Additionally, due to a lack of profound knowledge in parallel computing, the program is scripted to run a bunch of R processes independently. "Communication" between them takes place via variables they read from and write to disc in order to have some sort of "shared environment" (horrible, I know ;-)). So here are my specific questions: 1) Is it possible to catch connection or timeout errors in RCurl functions that allow me to implement my customized error handling? If so, could you guide me to some examples, please? 2) Can I somehow identify "frozen" Rterm or Rscript processes (e.g. via using Sys.getpid()?) in order to shut them down and reinitialize them? You'll find my session info below. Thanks for any hints or advice! Janko > sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] LC_TIME=German_Germany.1252 attached base packages: [1] tcltk tools stats graphics grDevices utils datasets [8] methods base other attached packages: [1] RCurl_1.5-0.1bitops_1.0-4.1 XML_3.2-0.2 RMySQL_0.7-5 [5] filehash_2.1-1 hash_2.0.1 timeDate_2130.91 RODBC_1.3-2 [9] MiscPsycho_1.6 statmod_1.4.8debug_1.2.4 mvbutils_2.5.4 [13] DBI_0.2-5cwhmisc_2.1 lattice_0.19-13 loaded via a namespace (and not attached): [1] grid_2.12.1 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Error handling with frozen RCurl function calls + Identification of frozen R processes
Dear list, I'm tackling an empiric research problem that requires me to address a whole bunch of conceptual and/or technical details at the same time which cuts time short for all the nitty-gritty details of the "components" involved. Having said this, I'm lacking the time at the moment to deeply dive into parallel computing and HTTP requests via RCurl and I hope you can help me out with one or two imminent issues of my crawler/scraper: Once a day, I'm running 'RCurl::getURIAsynchronous(x=URL.frontier.sub, multiHandle=my.multi.handle)' within an lapply()-construct in order to read chunks of deterministically composed URLs from a host. There are courtesy time delays implemented between the individual http requests (5 times the time the last request from this host took) so that I'm not clogging the host. I'm causing about 15 minutes of traffic per day. The problem is, that 'getURIAsynchronous()' simply freezes sometimes and I don't have a clue why so. I also can't reproduce the error as it's totally erratic. I tried to put the function inside a try() or tryCatch() construct to no avail. Also, I've experimented with a couple of timeout options of Curl, but honestly didn't really understand all the implications. None worked so far. It simply seems that upon an error 'getURIAsynchronous()' simply does not give control back to the R process. Additionally, due to a lack of profound knowledge in parallel computing, the program is scripted to run a bunch of R processes independently. "Communication" between them takes place via variables they read from and write to disc in order to have some sort of "shared environment" (horrible, I know ;-)). So here are my specific questions: 1) Is it possible to catch connection or timeout errors in RCurl functions that allow me to implement my customized error handling? If so, could you guide me to some examples, please? 2) Can I somehow identify "frozen" Rterm or Rscript processes (e.g. via using Sys.getpid()?) in order to shut them down and reinitialize them? You'll find my session info below. Thanks for any hints or advice! Janko > sessionInfo() R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] LC_TIME=German_Germany.1252 attached base packages: [1] tcltk tools stats graphics grDevices utils datasets [8] methods base other attached packages: [1] RCurl_1.5-0.1bitops_1.0-4.1 XML_3.2-0.2 RMySQL_0.7-5 [5] filehash_2.1-1 hash_2.0.1 timeDate_2130.91 RODBC_1.3-2 [9] MiscPsycho_1.6 statmod_1.4.8debug_1.2.4 mvbutils_2.5.4 [13] DBI_0.2-5cwhmisc_2.1 lattice_0.19-13 loaded via a namespace (and not attached): [1] grid_2.12.1 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] "Simulate" package namespace at development stage
Dear list, I was wondering if it is possible to create and use a package namespace at the development stage of a package. To clarify, I would like to make sure that my package functions (and not some other functions that happen to have identical names) are called by prepending function names appropriately (e.g. my.package::foo()). Is that possible before a package is actually build and loaded? If so, could you tell me how to do it? Thanks a lot! Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] setGeneric for residuals, etc
> -Ursprüngliche Nachricht- > Von: r-devel-boun...@r-project.org [mailto:r-devel-bounces@r- > project.org] Im Auftrag von Johann Hibschman > Gesendet: Donnerstag, 20. Januar 2011 16:25 > An: r-de...@stat.math.ethz.ch > Betreff: [Rd] setGeneric for residuals, etc > > I'm experimenting with a few model-fitting classes of my own. I'm > leaning towards using S4 for my classes, but the R functions I'd want > to > override (residuals, predict, etc.) are all S3 methods. > > As I understand it, I could do setGeneric("residuals"), then add S4 > specializations to it. However, I don't understand the full > consequences of doing this. Are there any drawbacks? Is there some > code that will not run properly if I do this? It feels like I'm > reaching in and modifying a core R function, which makes me nervous. > > To put it another way, if it's completely transparent and causes no > problems, why isn't it done by default? > > (If it matters, I'm still on 2.10.1, but I can take it up with global > architecture if there are compelling changes in later versions.) > > Thanks, > Johann > Well, one "drawback" with S4 is that you need to write more explicit code than in a pure S3 world, but it makes your code also a lot more robust (method dispatch, validation etc.). As far as I understand it, working with customized S4 objects would imply that you need to specify methods for all those S3 functions already out there that you want to work with your objects. For example, inside your method for 'residuals()', you will probably just get some data out of a slot of your object and run the S3 function 'residuals(your.slot.data)'. So there's nothing that should make you nervous in that respect, you're not overwriting anything with your method. Setting a generic for an existing function is just a necessary step in order to specify S4 methods for it. However, you could also write a couple methods that coerce your custom object into those S3 objects that the already implemented functions expect (e.g. 'residuals()'). Another drawback might be efficiency depending on how complex your S4 objects are (e.g. how many nested function calls are required to get to actual data). HTH, Janko > __ > 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
[Rd] Reference Classes: how to clone/copy instances?
Dear list, I don't know what's the correct term for this in the OOP context, but is it possible to "clone"/copy an instance of a reference class (say 'a') so that I get an *autonomous* second instance 'b'? Autonomous in the sense that changes to 'a' do not affect 'b'. I know that this is somewhat against the pass-by-reference paradigm, but the motive behind this is to generalize the 'undo()' functionality described in the example of 'setRefClass()' to entire objects: I'd like to generate "images" of my object via a '$imageAdd()" method in order to generate a change history of the object (images are assigned to a field '.IMAGES' of class 'environment') that I can "load()" on demand to undo changes to my object. Obviously, simply assigning 'b <- a' does not work with respect to autonomy. Nor does exporting the object via 'b <- a$export(Class="A")'. I thought about creating a new instance b and then defining a function that maps the field values from a to b: b <- getRefClass("A")$new() fieldsMap(src=a, tgt=b) Is there already some functionality I can use? Thanks, Janko ## SYSTEM INFO ## Windows XP SP3 R 2.12.0 (patched as of 2010-11-22) Eclipse 3.6.1 (Helios) StatET 0.9.x ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Reference Classes: removing methods -> implications for objects/instances of that class
Dear list, just to make sure that I understand 'unregistering' methods for S4 reference classes correctly: If I registered a method and want to 'unregister' (i.e. remove) this method again, objects/instance created of the respective class still feature the removed method until I do an explicit reassign ('my.instance <- getRefClass("Classname")$new()'), right? setRefClass("Shab", fields=list(a="numeric")) # Register method getRefClass("Shab")$methods(list(aSquare=function() a^2)) getRefClass("Shab")$methods() # Create instance shab<- getRefClass("Shab")$new() shab$a <- 10 # Use method shab$aSquare() # Remove method getRefClass("Shab")$methods(list(aSquare=NULL)) getRefClass("Shab")$methods() # Gone. shab$aSquare() # Still possible shab<- getRefClass("Shab")$new() shab$aSquare() # Not possible anymore Is it also possible to remove a method so that all instances do not feature the respective method anymore without having to resort to an explicit reassign? Or is this technically not possible or not a desired feature? TIA, Janko ## SYSTEM INFO ## Windows XP SP3 R 2.12.0 (patched as of 2010-11-22) Eclipse 3.6.1 (Helios) StatET 0.9.x ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] Catching a RCurl error?
> -Ursprüngliche Nachricht- > Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > Im Auftrag von Tal Galili > Gesendet: Dienstag, 23. November 2010 14:18 > An: r-h...@r-project.org > Betreff: [R] Catching a RCurl error? > > Hi all, > > I'm running a complex script which accesses the internet, and sometimes > it > stops with the error: > > Error in curlPerform(url = url, headerfunction = header$update, curl = > curl, > > : > > Failure when receiving data from the peer > > > Is there a way to make the script "wait" longer, or not crash when this > error happens? > > (I'm wondering if this should be done in the level of tryCatch, or by > playing with some parameter in the RCurl options) > > > Thanks, > Tal That's a question that also popped up in my work. You can definitely tune timeouts in the options (e.g. one options of interest in that respect is CURLOPT_TIMEOUT, which I think is lowercase in the R implementation; there are others, too; check http://curl.haxx.se/docs/manual.html and http://curl.haxx.se/libcurl/c/libcurl-tutorial.html). Generally there's a lot of stuff you can specify but I haven't found a way yet to use some sort of an "internal error control". Putting a tryCatch() or try() wrapper around your CURL request is nice and good, but the error of interest usually happens "inside" (or "with") the actual request which in my case usually freezes the routine, so control is never handed back to R --> try() was useless for me. If you find something in that respect I'd be also very interested in your solution # SYSTEM INFO # Windows XP SP3 R 2.12.0 (patched as of 2010-11-22) Eclipse 3.6.1 (Helios) StatET 0.9.x # > > > > Contact > Details:--- > Contact me: tal.gal...@gmail.com | 972-52-7275845 > Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) > | > www.r-statistics.com (English) > --- > --- > > [[alternative HTML version deleted]] > > __ > r-h...@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-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] reference classes: question on inheritance
> -Ursprüngliche Nachricht- > Von: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r- > project.org] Im Auftrag von John Chambers > Gesendet: Montag, 22. November 2010 18:51 > An: r-devel@r-project.org > Betreff: Re: [Rd] reference classes: question on inheritance > > >> > >> What am I doing wrong here? > > Not using a recent enough version of R probably (and not telling us > what > version you are using). > > The warning (not an error) should not appear in current r-devel or > 2.12-patched. In other words, works fine for me. > > John Thanks, I didn't even know there existed a patched build as I usually skipped the x.x.0 versions of R. But ref classes really seemed worth a try. Cheers, Janko # SYSTEM INFO # Windows XP SP3 R 2.12.0 (patched as of 2010-11-22) Eclipse 3.6.1 (Helios) StatET 0.9.1 # > > On 11/21/10 3:40 PM, Janko Thyson wrote: > > Hmm, interesting: it's the virtual class that causes the trouble. If > a > > virtual class is a ref class, everything works fine. If it's a > standard S4 > > class, it results in the error below. > > > > Regards, > > Janko > > > >> -Ursprüngliche Nachricht- > >> Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de] > >> Gesendet: Montag, 22. November 2010 00:31 > >> An: 'r-de...@r-project. org' > >> Betreff: reference classes: question on inheritance > >> > >> Dear list, > >> > >> I have a reference class which should act as a generic superclass > for > >> other classes. Ive read the respective section at ?setRefClass and > put > >> the name of the superclass to the contains argument of an example > >> subclass (see class defs below). Classnames are set in a way that > >> shouldnt result in collation issues (virtual def sourced before > >> superclass def sourced before subclass). Yet, this results in the > >> following error: > >> > >> Warnmeldung: > >> unable to find a consistent ordering of superclasses for class > >> "Shabubu": order chosen is inconsistent with the superclasses of > >> "JObject" > >> > >> ## CLASS DEFS # > >> setClass("JObjectVirtual") > >> setRefClass( > >>Class="JObject", > >>fields=list( > >># GENERIC FIELDS (DON'T CHANGE !!!) > >>.BUFFER="environment", > >>.GENESIS="environment", > >>.HISTORY="environment", > >>.IMAGES="environment", > >>.LOGS="environment", > >>.OPTS="environment", > >>.PLUGINS="environment", > >>.TMP="environment", > >>.UID="character", > >>DATA="data.frame" > >># / > >>), > >>contains=c("JObjectVirtual"), > >>methods=list( > >>... > >>) > >> ) > >> setRefClass( > >>Class="Shabubu", > >>fields=list( > >># CUSTOM FIELDS (ADAPT TO YOUR NEEDS) > >>a="numeric", > >>b="character", > >>c="logical", > >>d="data.frame", > >>e="matrix", > >>f="list", > >>derived.field="function" > >># / > >>), > >>contains=c("JObject") > >> ) > >> > >> Thanks, > >> Janko > > > > __ > > 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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] reference classes: question on inheritance
Hmm, interesting: it's the virtual class that causes the trouble. If a virtual class is a ref class, everything works fine. If it's a standard S4 class, it results in the error below. Regards, Janko > -Ursprüngliche Nachricht- > Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de] > Gesendet: Montag, 22. November 2010 00:31 > An: 'r-de...@r-project. org' > Betreff: reference classes: question on inheritance > > Dear list, > > I have a reference class which should act as a generic superclass for > other classes. Ive read the respective section at ?setRefClass and put > the name of the superclass to the contains argument of an example > subclass (see class defs below). Classnames are set in a way that > shouldnt result in collation issues (virtual def sourced before > superclass def sourced before subclass). Yet, this results in the > following error: > > Warnmeldung: > unable to find a consistent ordering of superclasses for class > "Shabubu": order chosen is inconsistent with the superclasses of > "JObject" > > ## CLASS DEFS # > setClass("JObjectVirtual") > setRefClass( > Class="JObject", > fields=list( > # GENERIC FIELDS (DON'T CHANGE !!!) > .BUFFER="environment", > .GENESIS="environment", > .HISTORY="environment", > .IMAGES="environment", > .LOGS="environment", > .OPTS="environment", > .PLUGINS="environment", > .TMP="environment", > .UID="character", > DATA="data.frame" > # / > ), > contains=c("JObjectVirtual"), > methods=list( > ... > ) > ) > setRefClass( > Class="Shabubu", > fields=list( > # CUSTOM FIELDS (ADAPT TO YOUR NEEDS) > a="numeric", > b="character", > c="logical", > d="data.frame", > e="matrix", > f="list", > derived.field="function" > # / > ), > contains=c("JObject") > ) > > What am I doing wrong here? > > Thanks, > Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] reference classes: question on inheritance
Dear list, I have a reference class which should act as a "generic" superclass for other classes. I've read the respective section at ?setRefClass and put the name of the superclass to the 'contains' argument of an example subclass (see class defs below). Classnames are set in a way that shouldn't result in collation issues (virtual def sourced before superclass def sourced before subclass). Yet, this results in the following error: Warnmeldung: unable to find a consistent ordering of superclasses for class "Shabubu": order chosen is inconsistent with the superclasses of "JObject" ## CLASS DEFS # setClass("JObjectVirtual") setRefClass( Class="JObject", fields=list( # GENERIC FIELDS (DON'T CHANGE !!!) .BUFFER="environment", .GENESIS="environment", .HISTORY="environment", .IMAGES="environment", .LOGS="environment", .OPTS="environment", .PLUGINS="environment", .TMP="environment", .UID="character", DATA="data.frame" # / ), contains=c("JObjectVirtual"), methods=list( ... ) ) setRefClass( Class="Shabubu", fields=list( # CUSTOM FIELDS (ADAPT TO YOUR NEEDS) a="numeric", b="character", c="logical", d="data.frame", e="matrix", f="list", derived.field="function" # / ), contains=c("JObject") ) What am I doing wrong here? Thanks, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Ref classes: can I register fields as I register methods?
Hi there, is it possible to register fields as you can register methods with getRefClass("Classname")$methods(.)? I know that you should usually give some thought on which fields you need and hardcode them in the class def. But I'm playing around with dynamically creating/extending sort of a template class that already offers basic functionality shared by all objects that "inherit" from that class. If I follow the usual inheritance paradigm I would have to actually define those new "subclasses" and let them inherit from the superclass (contains argument(, right? But can I get around that by sort of registering new fields? Maybe with 'initFields(.)'? Thanks for any info on that, Janko # SYSTEM INFO # Windows XP SP3 R 2.12.0 Eclipse 3.6.1 (Helios) StatET 0.9.1 # [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Compiling R 2.12.0 from source: error (temp dir)
Puh, heres where Im at right now: - I reinstalled Rtools (2.12) to C:\Rtools (full installation) left the default for R Root dir = C:\R and R 64 root dir = C:\R64, - I noticed that theres a Tcl directory in C:\R now -> is that what I need regarding my previous Tcl/Tk issue down the building process? Or do I still need to install Tcl in any way? - I checked my Windows PATH if it exactly reflects the recommendations in the admin manual, - I set a windows environment variable TMPDIR=C:/temp And now Im back to my old error regarding the temp dir because its somehow still set to /tmp. cannot create /tmp/R4156: directory nonexistent mv: cannot stat `/tmp/R4156': No such file or directory make[3]: *** [mkR] Error 1 make[2]: *** [all] Error 2 make[1]: *** [R] Error 1 make: *** [all] Error 2 Any ideas? Im really trying ;-) Thanks, Janko # SYSTEM INFO # Windows XP SP3 R 2.12.0 Eclipse 3.6.1 (Helios) StatET 0.9.x # > -Ursprüngliche Nachricht----- > Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de] > Gesendet: Donnerstag, 18. November 2010 16:38 > An: 'Duncan Murdoch' > Cc: 'r-de...@r-project. org' > Betreff: AW: [Rd] Compiling R 2.12.0 from source: error (temp dir) > > Sorry, but I'm still kind of puzzled on this one ;-) > > Found the Tcl/Tk section in the manual but I don't really understand > where I have to set those options. Append it to 'make all recommended'? > I checked 'make --help' which didn't list any such options. Or does > that refer to the installation of Tcl/Tk itself? I downloaded and > installed the binary version of Tcl/Tk (ActiveTcl > http://downloads.activestate.com/ActiveTcl/releases/8.5.9.0/ActiveTcl8. > 5.9.0.293667-win32-ix86-threaded.exe) and as far as I understand, I now > need to link that to the tcltk package of R, right? I don't know how I > would install Tcl/Tk from its sources, but if that's the better choice: > could anyone drop me the command line(s) I need to execute in order to > install and link Tcl/Tk to my R (pre-)build? > > Thanks a lot, > Janko > > SECTION FROM THE MANUAL (P. 32): > A.2.1 Tcl/Tk > The tcltk package needs Tcl/Tk >= 8.4 installed: the sources are > available at http:// > www.tcl.tk/. To specify the locations of the Tcl/Tk files you may need > the configuration > options > --with-tcltk > use Tcl/Tk, or specify its library directory > --with-tcl-config=TCL_CONFIG > specify location of tclConfig.sh > --with-tk-config=TK_CONFIG > specify location of tkConfig.sh > or use the configure variables TCLTK_LIBS and TCLTK_CPPFLAGS to specify > the flags needed > for linking against the Tcl and Tk libraries and for finding the > tcl.h and tk.h headers, > respectively. If you have both 32- and 64-bit versions of Tcl/Tk > installed, specifying the paths > to the correct config files may be necessary to avoid confusion between > them. > > SYSTEM INFO: > - Windows XP SP 3 > - R-2.12.0 > - Eclipse 3.6.1 > - StatET 0.9.x > > > -Ursprüngliche Nachricht- > > Von: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] > > Gesendet: Donnerstag, 18. November 2010 12:54 > > An: Janko Thyson > > Cc: 'r-de...@r-project. org' > > Betreff: Re: [Rd] Compiling R 2.12.0 from source: error (temp dir) > > > > On 18/11/2010 5:40 AM, Janko Thyson wrote: > > > I've created a /tmp directory so I wouldn't have to change TMPDIR. > So > > far, > > > so good. But now I get the error below. Anything I forgot regarding > > tcltk? > > > > Looks as if you forgot to install it. > > > > Duncan Murdoch > > > > > > > > Thx, > > > Janko > > > > > > ERROR: > > > In file included from init.c:22:0: > > > tcltk.h:23:17: fatal error: tcl.h: No such file or directory > > > compilation terminated. > > > make[4]: *** [init.o] Error 1 > > > make[3]: *** [mksrc-win] Error 1 > > > make[2]: *** [all] Error 2 > > > make[1]: *** [R] Error 1 > > > make: *** [all] Error 2 > > > > > > SYSTEM INFO: > > > - Windows XP SP 3 > > > - R-2.12.0 > > > - Eclipse 3.6.1 > > > - StatET 0.9.x > > > > > >> -Ursprüngliche Nachricht- > > >> Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de] > > >> Gesendet: Donnerstag, 18. November 2010 11:13 > > >> An: 'Prof Brian Ripley' > > >> Cc: 'r-de...@r-project. org' > > >> Betreff: AW: [Rd] Compiling R 2.12.0 from source: error (temp dir
Re: [Rd] Compiling R 2.12.0 from source: error (temp dir)
Sorry, but I'm still kind of puzzled on this one ;-) Found the Tcl/Tk section in the manual but I don't really understand where I have to set those options. Append it to 'make all recommended'? I checked 'make --help' which didn't list any such options. Or does that refer to the installation of Tcl/Tk itself? I downloaded and installed the binary version of Tcl/Tk (ActiveTcl http://downloads.activestate.com/ActiveTcl/releases/8.5.9.0/ActiveTcl8.5.9.0 .293667-win32-ix86-threaded.exe) and as far as I understand, I now need to link that to the tcltk package of R, right? I don't know how I would install Tcl/Tk from its sources, but if that's the better choice: could anyone drop me the command line(s) I need to execute in order to install and link Tcl/Tk to my R (pre-)build? Thanks a lot, Janko SECTION FROM THE MANUAL (P. 32): A.2.1 Tcl/Tk The tcltk package needs Tcl/Tk >= 8.4 installed: the sources are available at http:// www.tcl.tk/. To specify the locations of the Tcl/Tk files you may need the configuration options --with-tcltk use Tcl/Tk, or specify its library directory --with-tcl-config=TCL_CONFIG specify location of tclConfig.sh --with-tk-config=TK_CONFIG specify location of tkConfig.sh or use the configure variables TCLTK_LIBS and TCLTK_CPPFLAGS to specify the flags needed for linking against the Tcl and Tk libraries and for finding the tcl.h and tk.h headers, respectively. If you have both 32- and 64-bit versions of Tcl/Tk installed, specifying the paths to the correct config files may be necessary to avoid confusion between them. SYSTEM INFO: - Windows XP SP 3 - R-2.12.0 - Eclipse 3.6.1 - StatET 0.9.x > -Ursprüngliche Nachricht- > Von: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] > Gesendet: Donnerstag, 18. November 2010 12:54 > An: Janko Thyson > Cc: 'r-de...@r-project. org' > Betreff: Re: [Rd] Compiling R 2.12.0 from source: error (temp dir) > > On 18/11/2010 5:40 AM, Janko Thyson wrote: > > I've created a /tmp directory so I wouldn't have to change TMPDIR. So > far, > > so good. But now I get the error below. Anything I forgot regarding > tcltk? > > Looks as if you forgot to install it. > > Duncan Murdoch > > > > > Thx, > > Janko > > > > ERROR: > > In file included from init.c:22:0: > > tcltk.h:23:17: fatal error: tcl.h: No such file or directory > > compilation terminated. > > make[4]: *** [init.o] Error 1 > > make[3]: *** [mksrc-win] Error 1 > > make[2]: *** [all] Error 2 > > make[1]: *** [R] Error 1 > > make: *** [all] Error 2 > > > > SYSTEM INFO: > > - Windows XP SP 3 > > - R-2.12.0 > > - Eclipse 3.6.1 > > - StatET 0.9.x > > > >> -Ursprüngliche Nachricht- > >> Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de] > >> Gesendet: Donnerstag, 18. November 2010 11:13 > >> An: 'Prof Brian Ripley' > >> Cc: 'r-de...@r-project. org' > >> Betreff: AW: [Rd] Compiling R 2.12.0 from source: error (temp dir) > >> > >>> -Ursprüngliche Nachricht- > >>> Von: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] > >>> Gesendet: Mittwoch, 17. November 2010 18:42 > >>> An: Janko Thyson > >>> Cc: 'r-de...@r-project. org' > >>> Betreff: Re: [Rd] Compiling R 2.12.0 from source: error (temp dir) > >>> > >>> Is this on Windows? (Please do consult the posting guide and tell > us > >>> the 'at a minimum' information we asked for.) > >>> > >>> If so, it seems you forget the bit about setting TMPDIR right at > the > >>> top of the section on 'Building the core files': > >>> > >>> Set the environment variable @env{TMPDIR} to point to a > writable > >>> directory, with a path specified with forward slashes and no > >> spaces. > >>> (The default is @file{/tmp}, which may not be useful on > Windows.) > >>> > >> > >> Sorry, I always forget to provide that info. > >> > >> Could you tell me where/how I have to set TMPDIR? I've looked in > >> MkRules.local but didn't find anything. Or is that an argument at > 'make > >> all recommended'? > >> > >> Thanks, > >> Janko > >> > >> SYSTEM INFO: > >> - Windows XP SP 3 > >> - R-2.12.0 > >> - Eclipse 3.6.1 > >> - StatET 0.9.x > >> > >>> On Wed, 17 Nov 2010, Janko Thyson wrote: > >>> > >>>> Dear list, > >>>
Re: [Rd] Compiling R 2.12.0 from source: error (temp dir)
I've created a /tmp directory so I wouldn't have to change TMPDIR. So far, so good. But now I get the error below. Anything I forgot regarding tcltk? Thx, Janko ERROR: In file included from init.c:22:0: tcltk.h:23:17: fatal error: tcl.h: No such file or directory compilation terminated. make[4]: *** [init.o] Error 1 make[3]: *** [mksrc-win] Error 1 make[2]: *** [all] Error 2 make[1]: *** [R] Error 1 make: *** [all] Error 2 SYSTEM INFO: - Windows XP SP 3 - R-2.12.0 - Eclipse 3.6.1 - StatET 0.9.x > -Ursprüngliche Nachricht- > Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de] > Gesendet: Donnerstag, 18. November 2010 11:13 > An: 'Prof Brian Ripley' > Cc: 'r-de...@r-project. org' > Betreff: AW: [Rd] Compiling R 2.12.0 from source: error (temp dir) > > > -Ursprüngliche Nachricht- > > Von: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] > > Gesendet: Mittwoch, 17. November 2010 18:42 > > An: Janko Thyson > > Cc: 'r-de...@r-project. org' > > Betreff: Re: [Rd] Compiling R 2.12.0 from source: error (temp dir) > > > > Is this on Windows? (Please do consult the posting guide and tell us > > the 'at a minimum' information we asked for.) > > > > If so, it seems you forget the bit about setting TMPDIR right at the > > top of the section on 'Building the core files': > > > >Set the environment variable @env{TMPDIR} to point to a writable > >directory, with a path specified with forward slashes and no > spaces. > >(The default is @file{/tmp}, which may not be useful on Windows.) > > > > Sorry, I always forget to provide that info. > > Could you tell me where/how I have to set TMPDIR? I've looked in > MkRules.local but didn't find anything. Or is that an argument at 'make > all recommended'? > > Thanks, > Janko > > SYSTEM INFO: > - Windows XP SP 3 > - R-2.12.0 > - Eclipse 3.6.1 > - StatET 0.9.x > > > On Wed, 17 Nov 2010, Janko Thyson wrote: > > > > > Dear list, > > > > > > > > > > > > I've just tried to compile R 2.12.0 from source as I think I found > an > > error > > > in a C function that I would like to fix and check before I go > ahead > > with > > > posting the presumed error. > > > > > > > > > > > > I've got the R Toolset 2.12 installed and configured correctly and > > followed > > > the Admin manual closely (including the entire bitmap stuff; exact > > same > > > versions as in the manual). Also, all anti virus software is turned > > off (as > > > it complained on some .exe). I have Admin rights on my box. > > > > > > > > > > > > When I run 'make all recommended' I get the following error after a > > while: > > > > > > > > > > > > cannot create /tmp/R5436: directory nonexistent > > > > > > mv: cannot stat `/tmp/R5436': No such file or directory > > > > > > make[3]: *** [mkR] Error 1 > > > > > > make[2]: *** [all] Error 2 > > > > > > make[1]: *** [R] Error 1 > > > > > > make: *** [all] Error 2 > > > > > > > > > > > > Any ideas what this is about? Seems that the compiler can't create > a > > temp > > > directory because of a missing directory. > > > > > > > > > > > > Thanks for any hints, > > > > > > Janko > > > > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > R-devel@r-project.org mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-devel > > > > > > > -- > > Brian D. Ripley, rip...@stats.ox.ac.uk > > 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] Compiling R 2.12.0 from source: error (temp dir)
> -Ursprüngliche Nachricht- > Von: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] > Gesendet: Mittwoch, 17. November 2010 18:42 > An: Janko Thyson > Cc: 'r-de...@r-project. org' > Betreff: Re: [Rd] Compiling R 2.12.0 from source: error (temp dir) > > Is this on Windows? (Please do consult the posting guide and tell us > the 'at a minimum' information we asked for.) > > If so, it seems you forget the bit about setting TMPDIR right at the > top of the section on 'Building the core files': > >Set the environment variable @env{TMPDIR} to point to a writable >directory, with a path specified with forward slashes and no spaces. >(The default is @file{/tmp}, which may not be useful on Windows.) > Sorry, I always forget to provide that info. Could you tell me where/how I have to set TMPDIR? I've looked in MkRules.local but didn't find anything. Or is that an argument at 'make all recommended'? Thanks, Janko SYSTEM INFO: - Windows XP SP 3 - R-2.12.0 - Eclipse 3.6.1 - StatET 0.9.x > On Wed, 17 Nov 2010, Janko Thyson wrote: > > > Dear list, > > > > > > > > I've just tried to compile R 2.12.0 from source as I think I found an > error > > in a C function that I would like to fix and check before I go ahead > with > > posting the presumed error. > > > > > > > > I've got the R Toolset 2.12 installed and configured correctly and > followed > > the Admin manual closely (including the entire bitmap stuff; exact > same > > versions as in the manual). Also, all anti virus software is turned > off (as > > it complained on some .exe). I have Admin rights on my box. > > > > > > > > When I run 'make all recommended' I get the following error after a > while: > > > > > > > > cannot create /tmp/R5436: directory nonexistent > > > > mv: cannot stat `/tmp/R5436': No such file or directory > > > > make[3]: *** [mkR] Error 1 > > > > make[2]: *** [all] Error 2 > > > > make[1]: *** [R] Error 1 > > > > make: *** [all] Error 2 > > > > > > > > Any ideas what this is about? Seems that the compiler can't create a > temp > > directory because of a missing directory. > > > > > > > > Thanks for any hints, > > > > Janko > > > > > > [[alternative HTML version deleted]] > > > > __ > > R-devel@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > > > -- > Brian D. Ripley, rip...@stats.ox.ac.uk > 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
[Rd] WG: Reference classes: opinion on OOP design
Sorry, never sent an attachment before. I think my .R file didn't pass, so I'm attaching a .txt instead. -Ursprüngliche Nachricht- Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de] Gesendet: Mittwoch, 17. November 2010 19:56 An: 'r-de...@r-project. org' Betreff: Reference classes: opinion on OOP design Dear list, Im aware that this post does not really comply with the posting guide with respect to providing a minimal reproducible code example. But I do hope its okay that I spared uninterested readers by putting that into the attachment ;-) The thing is that Im not really familiar with true OOP as R is my first programming language. So I wanted to ask kindly for some expert opinion on a certain paradigm Ive come up with concerning my use of class defs and methods (S4 Reference Classes and S4 methods). MY GOAL: I thought itd be neat to have Reference Class instances that can - load data from remote places (e.g. a db, file whatever) on demand - enable field access in a static OR dynamic way: o static -> regular static field access (or if not initialized yet: retrieve data (optionally buffer it) -> write it to static field) o dynamic -> retrieve data (as it might have changed in the remote location in the meantime) and optionally buffer it for later use - enable sync of dynamic/buffer values with static field values (e.g. whenever the difference between static and dynamic value passes threshold x -> sync static and dynamic values. - Provide a value history (which might be useful for something ;-)) - Enable explicitly setting field values and facilitate their writeback to the remote location The instances should be flexible enough to work in an "static only" and "dynamic only" context and should make as much use of existing functionality (e.g. S4 classes, S4 method dispatch etc.) as possible. I do want to have the choice if Im carrying (possibly loads of) data with me in the fields of my object or if I compute/get them based on some function whenever I actually need it. For example, I'm thinking about parameter estimates that could automatically be reestimated based on rules that take into account a constantly changing data structure (new observations come it quite frequently or something like that). What do you think of the way Ive implemented this? Does this make sense to you or is something like this done in another (and probably more elegant ;-)) way? THE HOMEWORK I DID - Ive looked at active bindings which are nice. But this limits me to funs with either none or one argument if Im not mistaken. - I do like the idea of getRefClass(Blabla)$accessors( ) setting up get/set methods for me, but would need to customize them to my specific needs (e.g. handling the default values of method arguments etc.) Ive attached a code example and would really appreciate your comments if you find some time. Thanks a lot!! Janko #--- # CLASS DEF #--- Shabubu <- setRefClass( Class="Shabubu", fields=list( BUFFER="environment", HISTORY="environment", DYNCNTRL="environment", main="data.frame" ), methods=list( # GENERIC GENERATOR=function() getRefClass("Shabubu"), fields=function() GENERATOR()$fields(), methods=function() GENERATOR()$methods(), # accessors=function() GENERATOR()$accessors, # / # DATA RETRIEVAL data.retrieve=function() data.retrieve.core(.self=.self), # / # BUFFER buffer.refresh=function() assign("main", data.retrieve(), envir=BUFFER), buffer.clean=function() rm(list=ls(BUFFER, all.names=TRUE), envir=BUFFER), # / # DYNCNTRL dyncntrl.set=function(field, arg, val) { if(!exists(field, DYNCNTRL)) assign(field, new.env(parent=emptyenv()), DYNCNTRL) assign(arg, val, get(field, DYNCNTRL)) cat(paste("Setting '", arg, "=", val, "' for field '", field, "'.", sep=""), sep="\n") }, dyncntrl.get=function(field, arg) { if(!exists(field, DYNCNTRL)) return(NULL) if(!exists(arg, get(field, DYNCNTRL))) return(NULL) get(arg, get(field
[Rd] Reference classes: opinion on OOP design
Dear list, I'm aware that this post does not really comply with the posting guide with respect to "providing a minimal reproducible code example". But I do hope it's okay that I spared uninterested readers by putting that into the attachment ;-) The thing is that I'm not really familiar with "true" OOP as R is my first programming language. So I wanted to ask kindly for some expert opinion on a certain paradigm I've come up with concerning my use of class defs and methods (S4 Reference Classes and S4 methods). MY GOAL: I thought it'd be neat to have Reference Class instances that can - load data from remote places (e.g. a db, file whatever) on demand - enable field access in a static OR dynamic way: o static -> regular "static" field access (or if not initialized yet: retrieve data (optionally buffer it) -> write it to "static" field) o dynamic -> retrieve data (as it might have changed in the remote location in the meantime) and optionally buffer it for later use - enable sync of dynamic/buffer values with static field values (e.g. whenever the difference between static and dynamic value passes threshold x -> sync static and dynamic values. - Provide a value history (which might be useful for something ;-)) - Enable explicitly setting field values and facilitate their "writeback" to the remote location The instances should be flexible enough to work in an "static only" and "dynamic only" context and should make as much use of existing functionality (e.g. S4 classes, S4 method dispatch etc.) as possible. I do want to have the choice if I'm carrying (possibly loads of) data with me in the fields of my object or if I compute/get them based on some function whenever I actually need it. For example, I'm thinking about parameter estimates that could automatically be reestimated based on rules that take into account a constantly changing data structure (new observations come it quite frequently or something like that). What do you think of the way I've implemented this? Does this make sense to you or is something like this done in another (and probably more elegant ;-)) way? THE HOMEWORK I DID - I've looked at active bindings which are nice. But this limits me to funs with either none or one argument if I'm not mistaken. - I do like the idea of 'getRefClass("Blabla")$accessors(.)' setting up get/set methods for me, but would need to customize them to my specific needs (e.g. handling the default values of method arguments etc.) I've attached a code example and would really appreciate your comments if you find some time. Thanks a lot!! Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Compiling R 2.12.0 from source: error (temp dir)
Dear list, I've just tried to compile R 2.12.0 from source as I think I found an error in a C function that I would like to fix and check before I go ahead with posting the presumed error. I've got the R Toolset 2.12 installed and configured correctly and followed the Admin manual closely (including the entire bitmap stuff; exact same versions as in the manual). Also, all anti virus software is turned off (as it complained on some .exe). I have Admin rights on my box. When I run 'make all recommended' I get the following error after a while: cannot create /tmp/R5436: directory nonexistent mv: cannot stat `/tmp/R5436': No such file or directory make[3]: *** [mkR] Error 1 make[2]: *** [all] Error 2 make[1]: *** [R] Error 1 make: *** [all] Error 2 Any ideas what this is about? Seems that the compiler can't create a temp directory because of a missing directory. Thanks for any hints, Janko [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Reference classes: accessor functions via 'getRefClass(...)$accessors(...)'
Thanks a lot for the comments! I'll give the serveral alternatives a try to see if it gets me what I want. Cheers, Janko > -Ursprüngliche Nachricht- > Von: Vitalie S. [mailto:spinuvit.l...@gmail.com] > Gesendet: Mittwoch, 17. November 2010 13:51 > An: Janko Thyson > Cc: 'r-de...@r-project. org' > Betreff: Re: Reference classes: accessor functions via > 'getRefClass(...)$accessors(...)' > > "Janko Thyson" writes: > > > Hi there, > > > > I'd like to choose between an "static" and "dynamic" access of a > reference > > class field, say 'a'. > > > > myObj <- getRefClass("Blabla")$new() > > > > Static: myObj$a > > > > Dynamic: myObj$a.get() where the function retrieves the > data > > from a database (or some other location), stores it to a buffer and > > optionally updates the static field value 'a'. > > > > I've set up such a method 'a.get()' where I can actually decide > between > > static and dynamic runmode (so the method also wraps the call > 'myObj$a' for > > the static runmode). > > > > Now I saw that setting up such accessor methods (get/set) is already > done > > for me if I use 'getRefClass("Blabla")$accessors(.)'. I just don't > > understand what exactly I have to do there, because this results in > an > > error: 'getRefClass("Blabla")$accessors("a")' > > > > Can anyone point me to the correct use of > 'getRefClass(.)$accessors(.)'? > > It works for me: > > X <- setRefClass("XXX", fields = list(a = "character")) > X$accessors("a") > X > # ... > # Class Methods: > #"callSuper", "export", "getA", "import", "initFields", "setA" > # ... > > accessors() convenience method creates setA and getA functions: > > x <- X$new() > x$getA > #Class method definition for method getA() > #function () > #a > # > > HTH, > Vitalie. > > > > > > > Thanks a lot, > > > > Janko > > > > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Reference classes: accessor functions via 'getRefClass(...)$accessors(...)'
Hi there, I'd like to choose between an "static" and "dynamic" access of a reference class field, say 'a'. myObj <- getRefClass("Blabla")$new() Static: myObj$a Dynamic: myObj$a.get() where the function retrieves the data from a database (or some other location), stores it to a buffer and optionally updates the static field value 'a'. I've set up such a method 'a.get()' where I can actually decide between static and dynamic runmode (so the method also wraps the call 'myObj$a' for the static runmode). Now I saw that setting up such accessor methods (get/set) is already done for me if I use 'getRefClass("Blabla")$accessors(.)'. I just don't understand what exactly I have to do there, because this results in an error: 'getRefClass("Blabla")$accessors("a")' Can anyone point me to the correct use of 'getRefClass(.)$accessors(.)'? Thanks a lot, Janko [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R5 reference classes: how to initialize exactly?
> -Ursprüngliche Nachricht- > Von: Simon Urbanek [mailto:simon.urba...@r-project.org] > Gesendet: Mittwoch, 17. November 2010 11:35 > An: Janko Thyson > Cc: 'r-de...@r-project. org' > Betreff: Re: [Rd] R5 reference classes: how to initialize exactly? > > Just a clarification for posterity - R5 has nothing to do with the new > reference classes. It's not even an official name, but informally it's a > collection of ideas for an entirely new object system that can replace > both S3 and S4 (not that it will but it should be seen as having the > capability to do so technically). Reference classes are just an addition > to S4. > > Cheers, > Simon Thanks for that clarification. I picked that name up from the Google TechTalks presentation of Dirk and Romain. So I refer to them as S4 reference classes in future posts? Regards, Janko > > > On Nov 16, 2010, at 12:30 AM, Janko Thyson wrote: > > > Sorry, I was stupid: > > > > > > > > MyRefObj <- setRefClass("Blabla", .) > > > > > > > > One can always get the generator object of an defined class with > > 'getRefClass()'. So: > > > > > > > > g <- getRefClass("Blabla") > > > > x <- g$new(.) > > > > > > > > Regards, > > > > Janko > > > > > > > > > > > > Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de] > > Gesendet: Dienstag, 16. November 2010 00:27 > > An: 'r-de...@r-project. org' > > Betreff: R5 reference classes: how to initialize exactly? > > > > > > > > Dear List, > > > > > > > > So far, I really like those new R5 classes. But what kind of puzzles > me is > > that it's not just enough to define the actual reference class, I also > have > > to assign it to an object (e.g. 'MyRefObj') in order to fire > > 'MyRefObj$new(.)'. > > > > > > > > S4: > > > > setClass("Blabla", .) > > > > x <- new("Blabla") > > > > > > > > R5: > > > > MyRefObj <- setRefClass("Blabla", .) > > > > x <- MyRefObj$new(.) > > > > > > > > But then how do I define a reference class in a package that should be > > available after the package is loaded via 'library(my_pkg)' as there > is no > > 'MyRefObj' at startup yet? Do I have to call the script where the > definition > > lives? > > > > > > > > Thanks for any comments, > > > > Janko > > > > > > > > > > [[alternative HTML version deleted]] > > > > __ > > 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] R5 reference classes: how to initialize exactly?
Sorry, I was stupid: MyRefObj <- setRefClass("Blabla", .) One can always get the generator object of an defined class with 'getRefClass()'. So: g <- getRefClass("Blabla") x <- g$new(.) Regards, Janko Von: Janko Thyson [mailto:janko.thy...@ku-eichstaett.de] Gesendet: Dienstag, 16. November 2010 00:27 An: 'r-de...@r-project. org' Betreff: R5 reference classes: how to initialize exactly? Dear List, So far, I really like those new R5 classes. But what kind of puzzles me is that it's not just enough to define the actual reference class, I also have to assign it to an object (e.g. 'MyRefObj') in order to fire 'MyRefObj$new(.)'. S4: setClass("Blabla", .) x <- new("Blabla") R5: MyRefObj <- setRefClass("Blabla", .) x <- MyRefObj$new(.) But then how do I define a reference class in a package that should be available after the package is loaded via 'library(my_pkg)' as there is no 'MyRefObj' at startup yet? Do I have to call the script where the definition lives? Thanks for any comments, Janko [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R5 reference classes: how to initialize exactly?
Dear List, So far, I really like those new R5 classes. But what kind of puzzles me is that it's not just enough to define the actual reference class, I also have to assign it to an object (e.g. 'MyRefObj') in order to fire 'MyRefObj$new(.)'. S4: setClass("Blabla", .) x <- new("Blabla") R5: MyRefObj <- setRefClass("Blabla", .) x <- MyRefObj$new(.) But then how do I define a reference class in a package that should be available after the package is loaded via 'library(my_pkg)' as there is no 'MyRefObj' at startup yet? Do I have to call the script where the definition lives? Thanks for any comments, Janko [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Create NAMESPACE file as 'package.skeleton()' would do
Hi there, is there a way to create a NAMESPACE file based on Rd-files (or whatever is needed in order to apply the regular expression "^[[:alpha:]]+" without(!) resorting to package.skeleton() (as this kind of interferes with roxygenize() pretty often)? Thanks a lot, Janko [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Roxygen: @example tag does not work for me
> -Ursprüngliche Nachricht- > Von: h.wick...@gmail.com [mailto:h.wick...@gmail.com] Im Auftrag von > Hadley Wickham > Gesendet: Donnerstag, 4. November 2010 19:00 > An: Janko Thyson > Cc: r-de...@r-project. org > Betreff: Re: [Rd] Roxygen: @example tag does not work for me > > > I thought that @example would take the R code in "tests/foo.R" (this > file > > also exists) and append it to the .Rd-file. However, there is no > > \examples{...} section in my roxygen-processed .Rd-file after running > > roxygenize(). It just seems as if @example is just neglected. Should > I put > > the file in another directory? > > I would suspect that the path would be relative to either man/ or R/ - > so you probably want ../tests/... Thanks, I'll try that. > But including your unit tests as examples seems like a pretty odd > thing to do - they do serve rather different purposes. Sure. Don't know if "unit test" is a bit of an overkill name for my stuff. But I usually do poor man's testing of my functions in a script where I call the function with different settings. And I thought about tagging some parts of those scripts that qualify as good examples, have a routine that picks up those tagged sections and writes it to, say, "/inst/examples/foo.R". I could also create scripts that only feature good example code and use "@example .../inst/examples/foo.R" on it. No luck with that @example in general yet, though. I also tried appending the example code directly to the respective post-roxygenized .Rd-file in the man directory (write "\examples{ }"), but that doesn't get me anywhere either. Hitting "?foo" after the package has been build and installed does show the examples then, but the formatting is totally wrong (i.e. no "Examples" section header but just dumped right after the Note section etc.). I'm kinda out of clues now. Thanks for your comments though. Cheers, Janko > Hadley > > -- > Assistant Professor / Dobelman Family Junior Chair > Department of Statistics / Rice University > http://had.co.nz/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [Roxygen-devel] Roxygen: @example tag does not work for me
> -Ursprüngliche Nachricht- > Von: Vinh Nguyen [mailto:vqngu...@uci.edu] > Gesendet: Donnerstag, 4. November 2010 17:15 > An: Janko Thyson > Cc: r-de...@r-project. org > Betreff: Re: [Roxygen-devel] Roxygen: @example tag does not work for me > > I didn't know @example path/to/file.R was available until you > mentioned the UseR! 2010 presentation. If that's the case, I'm going > to guess that you have to specify use.Rd2=TRUE in roxygenize(), as > I've found most of the new features mentioned in that presentation to > require it. > Unfortunately, use.Rd2=TRUE also doesn't seem to work. > > On Thu, Nov 4, 2010 at 6:14 AM, Janko Thyson > wrote: > > > > Hi Vinh, > > > > thanks for the reply. What you suggest works just fine. It's not the > thing > > I'm looking for, though, since it means I have to "hard code" my > examples to > > the actual script. That's exactly what I'm trying to get around. And > there > > is this ominous "@example" tag that should get the job done, I just > don't > > get how ;-) > > > > Thanks for your comment though! > > > > Regards, Janko > > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [Roxygen-devel] Roxygen: @example tag does not work for me
> -Ursprüngliche Nachricht- > Von: roxygen-devel-boun...@lists.r-forge.r-project.org [mailto:roxygen- > devel-boun...@lists.r-forge.r-project.org] Im Auftrag von Vinh Nguyen > Gesendet: Donnerstag, 4. November 2010 04:04 > An: roxygen-de...@r-forge.wu-wien.ac.at > Betreff: Re: [Roxygen-devel] Roxygen: @example tag does not work for me > > Try @examples (with an 's'): > > #' @examples > #' my R code > #' my R code Hi Vinh, thanks for the reply. What you suggest works just fine. It's not the thing I'm looking for, though, since it means I have to "hard code" my examples to the actual script. That's exactly what I'm trying to get around. And there is this ominous "@example" tag that should get the job done, I just don't get how ;-) Thanks for your comment though! Regards, Janko > > I'm not sure if placing a relative path (tests/foo.R) would work...try > placing the actual code in the documentation chunk. > ___ > Roxygen-devel mailing list > roxygen-de...@lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/roxygen- > devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Roxygen: @example tag does not work for me
> -Ursprüngliche Nachricht- > Von: baptiste auguie [mailto:baptiste.aug...@googlemail.com] > Gesendet: Donnerstag, 4. November 2010 07:43 > An: Janko Thyson > Cc: r-de...@r-project. org > Betreff: Re: [Rd] Roxygen: @example tag does not work for me > > Hi, > > I think you could achieve this using the brew package. Define a > function that reads your external example file, and have brew insert > the resulting string in your script, which can then be processed by > roxygen. > > I'm curious to hear other suggestions, but I doubt it could work > out-of-the-box like you intended. > > HTH, > > baptiste Thanks a lot for the suggestion, I will have a look at brew. But I still think that "@example" is meant to do what I'm trying to do out-of-the box. At least it says so in the Roxygen manual (p. 19) and I found such a Roxygen line in the tutorial given at user! 2010 (http://roxygen.org/useR/roxygen-part-1.pdf, p. 25). Did anyone of you use "@example" yet? Cheers, Janko > > On 4 November 2010 01:50, Janko Thyson > wrote: > > Dear list, > > > > > > > > somehow I can't get the Roxygen tag "@example" to work for me. > > > > > > > > My "Roxygen-Header" of a script containing, say, a function looks > like this: > > > > > > > > #' My header > > > > #' > > > > #' My description > > > > #' > > > > #' @param a Blabla. > > > > #' @param b Blabla. > > > > #' @return \code{TRUE}. > > > > #' @callGraphPrimitives > > > > #' @references > > > > #' \url{http://www.something.org /} > > > > #' @author Janko Thyson \email{my.email@@something.com} > > > > #' @example tests/foo.R > > > > #' @seealso \code{\link{some.other.function}} > > > > Foo <- function(a, b){cat("Doing nothing useful.")} > > > > > > > > I thought that @example would take the R code in "tests/foo.R" (this > file > > also exists) and append it to the .Rd-file. However, there is no > > \examples{...} section in my roxygen-processed .Rd-file after running > > roxygenize(). It just seems as if @example is just neglected. Should > I put > > the file in another directory? > > > > > > > > The basic thing I'm trying to do is to have the "unit tests" for my > > functions organized in separate scripts and then plug in some of > their > > content as examples in the .Rd-files (this should be accomplished by > using > > in-source documentation à la Roxygen à thus something like "@example" > > pointing to such a script file would be very neat). I'd definitely > like to > > get around to "manually" specifying examples via the other tag > "@examples" > > as they will most likely lead to "out-of-sync" situations regarding > the unit > > test files. Any ideas? > > > > > > > > Thanks a lot! > > > > Janko > > > > > > > > > > __ > > 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
[Rd] Roxygen: @example tag does not work for me
Dear list, somehow I can't get the Roxygen tag "@example" to work for me. My "Roxygen-Header" of a script containing, say, a function looks like this: #' My header #' #' My description #' #' @param a Blabla. #' @param b Blabla. #' @return \code{TRUE}. #' @callGraphPrimitives #' @references #' \url{http://www.something.org /} #' @author Janko Thyson \email{my.email@@something.com} #' @example tests/foo.R #' @seealso \code{\link{some.other.function}} Foo <- function(a, b){cat("Doing nothing useful.")} I thought that @example would take the R code in "tests/foo.R" (this file also exists) and append it to the .Rd-file. However, there is no \examples{...} section in my roxygen-processed .Rd-file after running roxygenize(). It just seems as if @example is just neglected. Should I put the file in another directory? The basic thing I'm trying to do is to have the "unit tests" for my functions organized in separate scripts and then plug in some of their content as examples in the .Rd-files (this should be accomplished by using in-source documentation à la Roxygen à thus something like "@example" pointing to such a script file would be very neat). I'd definitely like to get around to "manually" specifying examples via the other tag "@examples" as they will most likely lead to "out-of-sync" situations regarding the unit test files. Any ideas? Thanks a lot! Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Including data in packages
Thanks, it works now! I accidentally chose the wrong folder, sorry for that. Now, if anyone could comment on the "hidden vs. non-hidden dataset" part of my questions he/she'd make my day ;-) Regards, Janko > -Ursprüngliche Nachricht- > Von: Rowe, Brian - Eqty NY [mailto:b.r...@baml.com] > Gesendet: Donnerstag, 14. Oktober 2010 21:35 > An: Janko Thyson > Betreff: RE: [Rd] Including data in packages > > Janko, > > You have to save the data objects you want into that directory in your > source package. Then when you build/install it will be there. > > Regards, > Brian > > > -Original Message- > From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r- > project.org] On Behalf Of Janko Thyson > Sent: Thursday, October 14, 2010 3:28 PM > To: 'Dirk Eddelbuettel' > Cc: 'r-de...@r-project. org' > Subject: Re: [Rd] Including data in packages > > Hi Dirk, > > thanks for the quick reply. So all datasets, regardless if they should > be > hidden from the user, should go into /data? If that's the convention, > that's > fine with me. But the problem is that there is no data-directory in > R_HOME/library/2-11.1/mypackage after running R CMD build and R CMD > INSTALL. > I've experimented with the options --binary and --use-zip-data but > without > luck. > > I think I don't understand the "optional directory" procedure in > general > yet: don't I just need to dump stuff in /data, /inst/doc, /exec etc. > and > have them "transferred" (sorry, I don't know a better word) to the > tar.gz > and eventually to the installed package? > > Regards, > Janko > > > -Ursprüngliche Nachricht- > > Von: Dirk Eddelbuettel [mailto:e...@debian.org] > > Gesendet: Donnerstag, 14. Oktober 2010 21:18 > > An: Janko Thyson > > Cc: r-de...@r-project. org > > Betreff: Re: [Rd] Including data in packages > > > > > > On 14 October 2010 at 21:06, Janko Thyson wrote: > > | The thing is that I don't understand how the actual 'transfer' > > happens when > > | the package is build and installed. Where do the objects 'live' > after > > | installation and how can I access them after firing > > library(mypackage)? For > > | example, there is a 'data' directory for package 'tm' > > | (R_HOME/R-2.11.1/library/tm) but such a directory is missing even > if > > I chose > > | option 3) (as stated above) to get my data included. Also, how can > I > > | actually execute the lazyload? > > > > If in doubt, copy existing packages, preferably recommended ones: > > > > e...@max:~/src/debian/CRAN$ find -type d -name data | sort > > ./boot-1.2.42/data > > ./boot-1.2.43/data > > ./car-2.0-2/data > > ./cluster-1.13.1/data > > ./effects-2.0.10/data > > ./fEcofin-290.76/data > > ./fExtremes-2100.77/data > > ./fGarch-2110.80/data > > ./fImport-2110.79/data > > ./fPortfolio-2110.79/data > > ./gdata-2.8.0/data > > ./gplots-2.8.0/data > > ./gtools-2.6.2/data > > ./lattice-0.19-11/data > > ./lattice-0.19-13/data > > ./latticeExtra-0.6-14/data > > ./lme4-0.999375-35/data > > ./lmtest-0.9.27/data > > ./MASS-7.3-7/data > > ./Matrix-0.999375-44/data > > ./misc3d-0.7-1/data > > ./multcomp-1.2-3/data > > ./nlme-3.1.96/data > > ./nlme-3.1.97/data > > ./nws-2.0.0.3/data > > ./rggobi-2.1.16/data > > ./robustbase-0.5-0-1/data > > ./rpart-3.1.46/data > > ./sandwich-2.2-6/data > > ./sm-2.2-4.1/data > > ./sn-0.4-16/data > > ./strucchange-1.4-1/data > > ./strucchange-1.4-2/data > > ./survival-2.35-8/data > > ./timeSeries-2120.89/data > > ./tseries-0.10-22/data > > ./urca-1.2-4/data > > e...@max:~/src/debian/CRAN$ > > > > The vote is clearly in favour of data/ over inst/data. > > > > Hth, Dirk > > > > -- > > Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > > -- > This message w/attachments (message) is intended solely for the use of > the intended recipient(s) and may contain information that is > privileged, confidential or proprietary. If you are not an intended > recipient, please notify the sender, and then please delete and destroy > all copies and attachments, and be advised that any review or > dissemination of, or the
Re: [Rd] Including data in packages
Hi Dirk, thanks for the quick reply. So all datasets, regardless if they should be hidden from the user, should go into /data? If that's the convention, that's fine with me. But the problem is that there is no data-directory in R_HOME/library/2-11.1/mypackage after running R CMD build and R CMD INSTALL. I've experimented with the options --binary and --use-zip-data but without luck. I think I don't understand the "optional directory" procedure in general yet: don't I just need to dump stuff in /data, /inst/doc, /exec etc. and have them "transferred" (sorry, I don't know a better word) to the tar.gz and eventually to the installed package? Regards, Janko > -Ursprüngliche Nachricht- > Von: Dirk Eddelbuettel [mailto:e...@debian.org] > Gesendet: Donnerstag, 14. Oktober 2010 21:18 > An: Janko Thyson > Cc: r-de...@r-project. org > Betreff: Re: [Rd] Including data in packages > > > On 14 October 2010 at 21:06, Janko Thyson wrote: > | The thing is that I don't understand how the actual 'transfer' > happens when > | the package is build and installed. Where do the objects 'live' after > | installation and how can I access them after firing > library(mypackage)? For > | example, there is a 'data' directory for package 'tm' > | (R_HOME/R-2.11.1/library/tm) but such a directory is missing even if > I chose > | option 3) (as stated above) to get my data included. Also, how can I > | actually execute the lazyload? > > If in doubt, copy existing packages, preferably recommended ones: > > e...@max:~/src/debian/CRAN$ find -type d -name data | sort > ./boot-1.2.42/data > ./boot-1.2.43/data > ./car-2.0-2/data > ./cluster-1.13.1/data > ./effects-2.0.10/data > ./fEcofin-290.76/data > ./fExtremes-2100.77/data > ./fGarch-2110.80/data > ./fImport-2110.79/data > ./fPortfolio-2110.79/data > ./gdata-2.8.0/data > ./gplots-2.8.0/data > ./gtools-2.6.2/data > ./lattice-0.19-11/data > ./lattice-0.19-13/data > ./latticeExtra-0.6-14/data > ./lme4-0.999375-35/data > ./lmtest-0.9.27/data > ./MASS-7.3-7/data > ./Matrix-0.999375-44/data > ./misc3d-0.7-1/data > ./multcomp-1.2-3/data > ./nlme-3.1.96/data > ./nlme-3.1.97/data > ./nws-2.0.0.3/data > ./rggobi-2.1.16/data > ./robustbase-0.5-0-1/data > ./rpart-3.1.46/data > ./sandwich-2.2-6/data > ./sm-2.2-4.1/data > ./sn-0.4-16/data > ./strucchange-1.4-1/data > ./strucchange-1.4-2/data > ./survival-2.35-8/data > ./timeSeries-2120.89/data > ./tseries-0.10-22/data > ./urca-1.2-4/data > e...@max:~/src/debian/CRAN$ > > The vote is clearly in favour of data/ over inst/data. > > Hth, Dirk > > -- > Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Including data in packages
Dear List, I would like to include a couple of objects in a package I am developing and I don't really get it yet. The objects should be available after package load as some functions depend on it. I tried the following: 1) Bundling all objects that I need in the file '/R/sysdata.rda' as described in the "Writing R Extensions" manual on page 7 2) Storing the objects in /inst/extdata/somedata.rda as described in the "Writing R Extensions" manual on page 9 3) Storing the objects in /data/somedata.rda to make it available via data() later on (I would like these objects from the user, though. So this isn't really my preferred option) In DESCRIPTION I flagged 'LazyLoad' to 'yes'. The thing is that I don't understand how the actual 'transfer' happens when the package is build and installed. Where do the objects 'live' after installation and how can I access them after firing library(mypackage)? For example, there is a 'data' directory for package 'tm' (R_HOME/R-2.11.1/library/tm) but such a directory is missing even if I chose option 3) (as stated above) to get my data included. Also, how can I actually execute the lazyload? Any hints are greatly appreciated! Thanks, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] How to set up an own package repository
Thank you very much for the advice! Cheers, Janko > -Ursprüngliche Nachricht- > Von: Friedrich Leisch [mailto:friedrich.lei...@stat.uni-muenchen.de] > Gesendet: Freitag, 17. September 2010 16:39 > An: Janko Thyson > Cc: r-de...@r-project. org > Betreff: Re: [Rd] How to set up an own package repository > > >>>>> On Fri, 17 Sep 2010 12:16:47 +0200, > >>>>> Janko Thyson (JT) wrote: > > > Dear List, > > I'd like to set up a package repository so I can use > install.packages() on > > it for home-grown packages. I set up an AMPP infrastructure on a > windows box > > already, but I'm pretty lost with respect to what to do next as I > didn't do > > any web-programming/admin yet. Could anyone recommend some r- > specific > > tutorials or has a couple of suggestions for me? I've had a look at > the > > official R manual, but it just describes the required repository > structure, > > but not how to implement that. I'd also be willing to dive into SVN > and > > alikes if you think that's best practice. > > If all machines involved can mount the repository as a network drive > you need no webserver at all, just use a file:/path/to/repository URL > for the repository. > > If you want a full featured web frontend you may want to have a look > at the Bioconductor scripts for generating repositories: > > http://bioconductor.org/packages/2.7/bioc/html/biocViews.html > > and especially > > http://bioconductor.org/packages/2.7/bioc/vignettes/biocViews/inst/doc/ > createReposHtml.pdf > > The scripts for CRAN are also in R but very specific for CRANs needs > ... > > 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-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] a small suggestion for improving the building of packages
fax (+61) 3 6232 5012 > mob (+61) 438 315 623 > > Kasper Daniel Hansen wrote: > > I agree with Kevin, I never run package.skeleton more than once. But > > one advantage to running it over and over again is if you change the > > names or the ordering of function arguments. That gets autowritten > > and I could see that being convenient if you change those a lot (as > > you sometime do in development) > > > > Kasper > > > > On Thu, Sep 16, 2010 at 5:17 PM, Kevin R. Coombes > > wrote: > >> The phrase that caught my attention in your post is the one about > >> "running package.skeleton() over and over". When I'm developing > >> packages, I never run it more than once. And I usually delete a lot > >> of the files it produces (since I like to organize my functions in > >> logical batches and not in separate files). And once I think I > >> have the file structure organized, I put everything under version > >> control and run future development out that system. > >> > >> Can you explain why you would need to re-run package.skeleton()? Is > >> there some use case that I am missing? > >> > >> Kevin > >> > >> On 9/16/2010 1:18 PM, Janko Thyson wrote: > >>> > >>> Dear Uwe, > >>> in principle, I totally agree with your point of politely forcing > >>> developers to write well documented packages. However, when you're > >>> trying to put together a package, you (or at least I) never get it > >>> completely right on the first, say, 20 tries ;-) Yet, by running > >>> package.skelleton() over and over to keep track of changes you made > >>> during the process, you overwrite all Rd files each time - > including > >>> the ones that you might already have put a lot of effort into. And > >>> delaying documentation to the very end of the process is probably > >>> not the best idea either ;-) IMHO the community should favor the > >>> approaches taken by packages such as roxygen or inlinedocs as at > >>> least it provides some sort of direct synchronization between code > >>> and documentation. Maybe one could agree on rejecting code that is > >>> missing roxygen or inlinedoc code, which would ensure that code is > >>> documented properly. In fact, isn't programming all about > >>> automating unnecessary manual procedures? I would count starting > >>> from scratch with all help files time and time again to be one of > >>> those unnecessary procedures. This time could better be invested in > >>> increasing the package's functionality. > >>> > >>> Best regards, my thanks go out to everyone as well, Janko > >> > >> __ > >> 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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] How to set up an own package repository
Dear List, I'd like to set up a package repository so I can use install.packages() on it for home-grown packages. I set up an AMPP infrastructure on a windows box already, but I'm pretty lost with respect to what to do next as I didn't do any web-programming/admin yet. Could anyone recommend some r-specific tutorials or has a couple of suggestions for me? I've had a look at the official R manual, but it just describes the required repository structure, but not how to implement that. I'd also be willing to dive into SVN and alikes if you think that's best practice. Thanks for any help whatsoever, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] a small suggestion for improving the building of packages
> -Ursprüngliche Nachricht- > Von: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] > Gesendet: Donnerstag, 16. September 2010 20:55 > An: Uwe Ligges > Cc: Janko Thyson; r-de...@r-project. org > Betreff: Re: [Rd] a small suggestion for improving the building of > packages > > On 16/09/2010 2:43 PM, Uwe Ligges wrote: > > > > On 16.09.2010 20:18, Janko Thyson wrote: > > >> From: Uwe Ligges > > >> Date: Wed, 15 Sep 2010 15:23:01 +0200 > > >> On 29.08.2010 22:34, Kyle Matoba wrote: > > >>> All, > > >>> > > >>> I just finished the process of build a package for the first > time and > > >> found > > >>> it characteristically (for R) very straightforward and well > > >> documented. > > >>> > > >>> Whenever I deal with open source software I always endeavor to > finish > > >> the > > >>> task I have in mind, and upon completing this, I then revisit > all of > > >> the > > >>> configurations, customizing as necessary to achieve my goals > more > > >> fully. > > >>> The ability to achieve some minimal level of functionality > without > > >> the > > >> need > > >>> for much filling in of configuration files, etc., is, I feel, > > >> important to > > >> > > >>> not scaring off the less technically inclined such as myself. > > >>> > > >>> Based on this heuristic, it is my understanding that a few small > > >> suggestions > > >>> could make building a warning-free package as easy as running > > >>> package.skeleton(), then R CMD check, R CMD build: > > >>> > > >>> - Fill in default titles for each of the '*.Rd' files in /man > > >>> - Take out the tildes in the 'examples' section of the '*- > package.Rd' > > >> main > > >> > > >>> documentation file for the package (it seems to confuse the > latex > > >> compiler) > > >>> - Put the lines '~~ Optionally other standard keywords, one per > line, > > >> from > > >> > > >>> file KEYWORDS in ~~ > > >>> ~~ the R documentation directory ~~' into the \references{} > section, > > >> there > > >> > > >>> is presently a warning about all text needing to be in a > section. > > >> Dear Kyle, > > >> thanks for the suggestions. Actually, it is intended to generate > > >> warnings / > > >> Errors in R CMD check: We want to force package developers to > document > > >> their > > >> packages probably. This way, package maintainers / developers > have to > > >> touch > > >> each Rd file and cannot use them as is in order to pass the > checks. > > >> Best wishes, > > >> uwe > > > > > > Dear Uwe, > > > in principle, I totally agree with your point of politely forcing > developers > > > to write well documented packages. However, when you're trying to > put > > > together a package, you (or at least I) never get it completely > right on the > > > first, say, 20 tries ;-) Yet, by running package.skelleton() over > and over > > > to keep track of changes you made during the process, you > overwrite all Rd > > > files each time - including the ones that you might already have > put a lot > > > of effort into. And delaying documentation to the very end of the > process is > > > probably not the best idea either ;-) IMHO the community should > favor the > > > approaches taken by packages such as roxygen or inlinedocs as at > least it > > > provides some sort of direct synchronization between code and > documentation. > > > Maybe one could agree on rejecting code that is missing roxygen or > inlinedoc > > > code, which would ensure that code is documented properly. In > fact, isn't > > > programming all about automating unnecessary manual procedures? I > would > > > count starting from scratch with all help files time and time > again to be > > > one of those unnecessary procedures. This time could better be > invested in > > > increasing the package's functionality. > > > > - I don't think package.skeleton overwrites files unless you ask for > it. > > > > - I think o
Re: [Rd] a small suggestion for improving the building of packages
> -Ursprüngliche Nachricht- > Von: William Dunlap [mailto:wdun...@tibco.com] > Gesendet: Donnerstag, 16. September 2010 20:45 > An: Janko Thyson; r-de...@r-project. org > Betreff: RE: [Rd] a small suggestion for improving the building of > packages > > > From: r-devel-boun...@r-project.org > > [mailto:r-devel-boun...@r-project.org] On Behalf Of Janko Thyson > > Sent: Thursday, September 16, 2010 11:19 AM > > To: r-de...@r-project. org > > Subject: Re: [Rd] a small suggestion for improving the > > building of packages > ... > > Dear Uwe, > > in principle, I totally agree with your point of politely > > forcing developers > > to write well documented packages. However, when you're trying to put > > together a package, you (or at least I) never get it > > completely right on the > > first, say, 20 tries ;-) Yet, by running package.skelleton() > > over and over > > to keep track of changes you made during the process, you > > overwrite all Rd > > files each time - including the ones that you might already > > have put a lot > > of effort into. > > Running package.skeleton more than once is destructive. > Perhaps it needs an update=TRUE/FALSE sort of option > to let you add functions and Rd templates. Uwe just pointed out that there is the argument 'force' that does that but since it said 'If FALSE will not overwrite an existing directory' I somehow didn't consider it to handle the update=TRUE/FALSE case. My bad. > > When I start a package I don't use package.skeleton, > mainly because it won't make all the usual directories > that I expect to eventually use: src, data, inst, test > (or it is tests?), etc. I'd rather that it made all > the usual directories (with the proper spelling) so > I could delete them if they ended up being empty. > Do other package writers use package.skeleton routinely? I agree. It would be nice if package.skeleton() would create a 'full-feature' skeleton removing empty directories during R CMD check. > > I copy a template package directory, edit the template > DESCRIPTION file, copy my code into the appropriate > subdirectories, and run prompt(func, filename="pkg/man/func.Rd") > on each function or dataset. The last step is a pain: > it would be nice if prompt had a dir= or destdir= argument > so that >prompt(func, destdir="pkg/man") > would make the file "pkg/man/func.Rd". > Oh, never really considered 'prompt()' before. Thanks for the suggestion! All the manuals always mention 'package.skeleton()' But couldn't you realize your destdir feature by just building a wrapper around 'prompt()' or using it in a sapply/lapply construct? The last couple of days I played around with Roxygen and together with a couple of utility-functions I managed to completely automate the whole process from creating a full-feature skeleton, processing the Rds with roxygenize() and running the full R CMD suite on the package. That way you document your code right within the actual script which I think is great. Best regards, Janko > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > > And delaying documentation to the very end of > > the process is > > probably not the best idea either ;-) IMHO the community > > should favor the > > approaches taken by packages such as roxygen or inlinedocs as > > at least it > > provides some sort of direct synchronization between code and > > documentation. > > Maybe one could agree on rejecting code that is missing > > roxygen or inlinedoc > > code, which would ensure that code is documented properly. In > > fact, isn't > > programming all about automating unnecessary manual > > procedures? I would > > count starting from scratch with all help files time and time > > again to be > > one of those unnecessary procedures. This time could better > > be invested in > > increasing the package's functionality. > > > > Best regards, my thanks go out to everyone as well, > > Janko > > > > > > Thanks, as always, to everyone for their hard work to keep my > > > statistical > > > > computing free and easy. > > > > > > > > Best, > > > > > > > > Kyle > > > > > > > > [[alternative HTML version deleted]] > > > > > > > > __ > > > > R-devel_at_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 > > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] a small suggestion for improving the building of packages
> From: Uwe Ligges > Date: Wed, 15 Sep 2010 15:23:01 +0200 > On 29.08.2010 22:34, Kyle Matoba wrote: > > All, > > > > I just finished the process of build a package for the first time and > found > > it characteristically (for R) very straightforward and well > documented. > > > > Whenever I deal with open source software I always endeavor to finish > the > > task I have in mind, and upon completing this, I then revisit all of > the > > configurations, customizing as necessary to achieve my goals more > fully. > > The ability to achieve some minimal level of functionality without > the > need > > for much filling in of configuration files, etc., is, I feel, > important to > > > not scaring off the less technically inclined such as myself. > > > > Based on this heuristic, it is my understanding that a few small > suggestions > > could make building a warning-free package as easy as running > > package.skeleton(), then R CMD check, R CMD build: > > > > - Fill in default titles for each of the '*.Rd' files in /man > > - Take out the tildes in the 'examples' section of the '*-package.Rd' > main > > > documentation file for the package (it seems to confuse the latex > compiler) > > - Put the lines '~~ Optionally other standard keywords, one per line, > from > > > file KEYWORDS in ~~ > > ~~ the R documentation directory ~~' into the \references{} section, > there > > > is presently a warning about all text needing to be in a section. > Dear Kyle, > thanks for the suggestions. Actually, it is intended to generate > warnings / > Errors in R CMD check: We want to force package developers to document > their > packages probably. This way, package maintainers / developers have to > touch > each Rd file and cannot use them as is in order to pass the checks. > Best wishes, > uwe Dear Uwe, in principle, I totally agree with your point of politely forcing developers to write well documented packages. However, when you're trying to put together a package, you (or at least I) never get it completely right on the first, say, 20 tries ;-) Yet, by running package.skelleton() over and over to keep track of changes you made during the process, you overwrite all Rd files each time - including the ones that you might already have put a lot of effort into. And delaying documentation to the very end of the process is probably not the best idea either ;-) IMHO the community should favor the approaches taken by packages such as roxygen or inlinedocs as at least it provides some sort of direct synchronization between code and documentation. Maybe one could agree on rejecting code that is missing roxygen or inlinedoc code, which would ensure that code is documented properly. In fact, isn't programming all about automating unnecessary manual procedures? I would count starting from scratch with all help files time and time again to be one of those unnecessary procedures. This time could better be invested in increasing the package's functionality. Best regards, my thanks go out to everyone as well, Janko > > Thanks, as always, to everyone for their hard work to keep my > statistical > > computing free and easy. > > > > Best, > > > > Kyle > > > > [[alternative HTML version deleted]] > > > > __ > > R-devel_at_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
[Rd] Roxygen: question regarding 'use.Rd2' and creation of DESCRIPTION
Dear List, I ran into the following two problems while using the package 'roxygen': QUESTION 1 I split the relevant R-Code for my package into the following scripts: classes.R (S4), functions.R ('standard' functions), generics.R (S4), methods.R (S4). Function package.skeleton() generates Rd-files for all class defs, function defs etc. in dir 'pkg/man'. So far, so good. Now, I'd like to run 'roxygenize()' on dir 'pkg' and face the problem that the argument 'use.Rd2' only works for parts of the Rd-files, no matter how it is specified. Setting it FALSE works for all non-S4 defs, setting it TRUE works for all S4-defs ('works' in the sense of ending up with non-empty \title{} in the Rd-files). However, both types of defs are in 'pkg/man' or 'pkg/R', respectivley. I implemented a workaround in which each of the four scripts is addressed separately by package.skeleton() and roxygenize(). The resulting Rd-files are stored in temp dirs (e.g. 'pkg/tmp_classes', 'pgk/tmp_functions' etc.) and are merged to 'pkg/man' at the very end of the process. But I figured there must be a better or at least more elegant way to do this. Any hints? I should mention that not all of my defs (be it non-S4 or S4) are already prepended with roxygen-code (related to this post http://stackoverflow.com/questions/2316356/can-roxygen-ignore-non-user-funct ions), yet the workaround creates non-empty \title{} for all Rd-files. Is this also possible by running package.skelleton() and roxygenize() just once? QUESTION 2 Even though I followed the roxygen vignette closely and also had a look at the webvis package as suggested here http://stackoverflow.com/questions/3086081/how-do-you-write-your-package-doc umentation, I still cannot reproduce a DESCRIPTION file that reflects the specifications I made via the part of the roxygen-code that is related to stating the package title, author etc. The outcome in the Rd file '-package.Rd' is fine, but the DESCRIPTION file itself still looks like the dummy created by package.skelleton. Am I doing something wrong here? Thanks very much for any suggestions, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Stats not loaded? Method for as.ts() results in error
Hi Jeff, sorry for that! I found the problem in the meanwhile. But since I'm always grateful to get answers from the list, here's what happened: I have a method for as.ts() setMethod(f = "as.ts", signature = "Tsi", definition = function(x, ...) { Function body }) This is the error I always got while running R CMD check Error in setMethod(f = "as.ts", signature = "Tsi", definition = function(x, : no existing definition for function "as.ts" What I was too stupid to see is the fact that as.ts() isn't a generic in the first place. Yet, I turned it into one somewhere in my code (which I forgot ;-)) and when I tried to debug my code manually I always misleadingly took it as an innate generic and wondered why R CMD check always complained about that fact that it couldn't find it. Regards, Janko > -Ursprüngliche Nachricht- > Von: Jeff Ryan [mailto:jeff.a.r...@gmail.com] > Gesendet: Freitag, 3. September 2010 15:57 > An: Janko Thyson > Cc: r-de...@r-project. org > Betreff: Re: [Rd] Stats not loaded? Method for as.ts() results in error > > Janko, > > You don't mention if you are using S3 or S4. A small example would > make it easier to identify where your problem is. > > Jeff > > On Fri, Sep 3, 2010 at 4:44 AM, Janko Thyson > wrote: > > Dear list, > > > > > > > > I've got the following problem: > > > > > > > > In a package I'm trying to build, there exists a method for the > function > > "as.ts()". When checking the package, R always throws the error that > it > > cannot find a function called "as.ts". To me it seems that the > package > > "stats" (home of "as.ts()") is not loaded during the checking process > even > > though it's a base package. For testing, I've written a method for > "plot()" > > to see if it's a general problem with base-functions, but this one > passes > > just fine. > > > > > > > > Did anyone of encounter a similar problem or could help me out with a > hint? > > > > > > > > Thank you very much, > > > > Janko > > > > > > > > > > __ > > R-devel@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > > > > > > > -- > Jeffrey Ryan > jeff.a.r...@gmail.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Stats not loaded? Method for as.ts() results in error
Dear list, I've got the following problem: In a package I'm trying to build, there exists a method for the function "as.ts()". When checking the package, R always throws the error that it cannot find a function called "as.ts". To me it seems that the package "stats" (home of "as.ts()") is not loaded during the checking process even though it's a base package. For testing, I've written a method for "plot()" to see if it's a general problem with base-functions, but this one passes just fine. Did anyone of encounter a similar problem or could help me out with a hint? Thank you very much, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Automatically retrieve correct collation
> -Ursprüngliche Nachricht- > Von: baptiste auguie [mailto:baptiste.aug...@googlemail.com] > Gesendet: Donnerstag, 19. August 2010 07:41 > An: Janko Thyson > Cc: r-de...@r-project. org > Betreff: Re: [Rd] Automatically retrieve correct collation > > Hi, > > roxygen can create the collate field for you, if you specify the > dependencies in the commented code. I've never tested it with S4 > classes though. > > HTH, > > baptiste Thanks Baptiste, I will have a look at Roxygen. Janko > > On 18 August 2010 22:28, Janko Thyson > wrote: > > Dear List, > > > > consider the following scenario: > > > > setClass(Class = "A", representation = representation(B = "B", C = > "C")) > > setClass(Class = "B", representation = representation(C = "C")) > > setClass(Class = "C", representation = representation(something = > > "character")) > > > > Obviously, the collation for sourcing these defs needs to be: C, B, > A. Which > > doesn't correspond to the default collation of R (alphabetically). > > > > I've tried to pick up on how to ensure the right collation when > building R > > Packages by reading some previous posts and as far as I understand > I've > > basically got two options here: > > 1) Put all class defs in one script, e.g. allClasses.R. > > 2) Manually specify the collation via the "Collate" field in the > DESCRIPTION > > file. > > > > I'm used to organizing my classes, generics, methods etc. on a > > "one-per-script" basis in various subdirectories (e.g. R/classes, > R/methods > > etc.) and try automate manual steps wherever possible (not sure if > that's > > the way most of you guys code, but it definitely helped me stay on > top of > > things). But this doesn't really go well with my two options above, > does it? > > ;-) > > > > So I thought about setting up a routine that > > - investigates the source code of all classes (via parsing and > looking into > > the "representation" argument) > > - finds out the valid collation by itself based on all classes that > it found > > in the representation argument of the respective class defs > > - and then writes all the class defs to one R script, e.g. > allClasses.R, so > > I can bundle all my code in an R Package without worrying about the > > collation. > > > > This way I could stick to my old habits while automating the process > of > > building a package a bit ;-) > > > > Now, I managed to get this done for "simple" class defs like the ones > above > > but haven't looked into more complex class defs (e.g. including > "contains" > > etc.) yet. > > > > Has anyone tried and succeeded in doing something similar or are all > of you > > into the "one-script-contains-all" paradigm? If anyone is interested, > I'd be > > glad to share code. Likewise I'd be interested in hearing about other > "best > > practices" in this respect. > > > > Best regards, > > Janko > > > > __ > > R-devel@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > > > > > -- > > > Dr. Baptiste Auguié > > Departamento de Química Física, > Universidade de Vigo, > Campus Universitario, 36310, Vigo, Spain > > tel: +34 9868 18617 > http://webs.uvigo.es/coloides > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Automatically retrieve correct collation
Dear List, consider the following scenario: setClass(Class = "A", representation = representation(B = "B", C = "C")) setClass(Class = "B", representation = representation(C = "C")) setClass(Class = "C", representation = representation(something = "character")) Obviously, the collation for sourcing these defs needs to be: C, B, A. Which doesn't correspond to the default collation of R (alphabetically). I've tried to pick up on how to ensure the right collation when building R Packages by reading some previous posts and as far as I understand I've basically got two options here: 1) Put all class defs in one script, e.g. allClasses.R. 2) Manually specify the collation via the "Collate" field in the DESCRIPTION file. I'm used to organizing my classes, generics, methods etc. on a "one-per-script" basis in various subdirectories (e.g. R/classes, R/methods etc.) and try automate manual steps wherever possible (not sure if that's the way most of you guys code, but it definitely helped me stay on top of things). But this doesn't really go well with my two options above, does it? ;-) So I thought about setting up a routine that - investigates the source code of all classes (via parsing and looking into the "representation" argument) - finds out the valid collation by itself based on all classes that it found in the representation argument of the respective class defs - and then writes all the class defs to one R script, e.g. allClasses.R, so I can bundle all my code in an R Package without worrying about the collation. This way I could stick to my old habits while automating the process of building a package a bit ;-) Now, I managed to get this done for "simple" class defs like the ones above but haven't looked into more complex class defs (e.g. including "contains" etc.) yet. Has anyone tried and succeeded in doing something similar or are all of you into the "one-script-contains-all" paradigm? If anyone is interested, I'd be glad to share code. Likewise I'd be interested in hearing about other "best practices" in this respect. Best regards, Janko __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] Problems building own package (Error: "package hasbeen build before R-2.10.0")
> -Ursprüngliche Nachricht- > Von: William Dunlap [mailto:wdun...@tibco.com] > Gesendet: Dienstag, 17. August 2010 22:25 > An: Janko Thyson > Betreff: RE: [Rd] [R] Problems building own package (Error: "package > hasbeen build before R-2.10.0") > > > ... > > > > R CMD check mypackage works fine (no errors, no warnings) > > > > > > > > R CMD build mypackage works fine (no errors, no warnings) > > > > > > > > R CMD INSTALL -library="C:\R\R-2.11.1\library" > > > > "something\mypackage\mypackage_1.0.tar.gz" works fine (no > > errors, no > > > > warnings) > > > > > > > > > > > > > > > > However, when I try loading the package in an R-Session (version > > > 2.11.1) via > > > > "library(mypackage)", R complains about the package being build > > > before > > > > version R-2.10.0 and tells me to rebuild it. > > Start R by typing 'R' (no other arguments) from the same > command window that you used for the 'R CMD ...' commands. > You ought to be able to load the package without warning > from that session. Compare the output of Sys.getenv("R_HOME") > and/or print(version) in that session and the in a session > that could not load the package without warnings. > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com Hi Bill, thanks for the suggestion. I don't quite get it, but even though version 2.11.1 was the only one in my PATH, it was always version 2.9.1 that was called when using R CMD. I could only resolve it by uninstalling version 2.9.1, which is totally fine considering we're at 2.11.1 now ;-) Janko > > > > > > > > > So the R that is in your PATH is < 2.10.x > > > Change your PATH and add the R version your are actually working > > > with > > > > As I wrote: "My PATH is set up as explained in the R-Admin > > manual. Also, the > > only R version stated there is "C:\R\R-2.11.1\bin;". > > > > > Uwe Ligges > > > > > > > > > > > > > > > > > > Could this possibly be due to the fact that I have multiple R > > > versions > > > > installed (this also includes the most recent one, though)? > > > > > > > > > > > > > > > > To provide you with some details: > > > > > > > > - Running Windows XP > > > > > > > > - All of my R versions are under "C:\R" (versions 2.9.2, > > > 2.10.1, > > > > 2.11.1). > > > > > > > > - I installed Rtools (version 2.1.2) to "C:\Rtools" and > > > pointed it > > > > to "C:\R" (as this was the default) to interact with R > > (should this > > > maybe > > > > have been "C:\R\R-2.11.1"?). I also installed everything else > > > necessary to > > > > build packages (Inno Setup etc.). > > > > > > > > - My PATH is set up as explained in R-Admin manual. > Also, > > > the only > > > > R version stated there is "C:\R\R-2.11.1\bin;". > > > > > > > > - I updated the DESCRIPTION file and specified > > all .Rd files > > > > correctly. > > > > > > > > > > > > > > > > Any idea what I'm doing wrong? > > > > > > > > > > > > > > > > Thanks a ton, > > > > > > > > Janko > > > > > > > > > > > > > > > >_ > > > > > > > > > > > > > > > > Janko Thyson > > > > <mailto:holger.ko...@ku-eichstaett.de> janko.thy...@ku- > > > eichstaett.de > > > > > > > > Catholic University of Eichstätt-Ingolstadt > > > > Ingolstadt School of Management > > > > Statistics and Quantitative Methods > > > > Auf der Schanz 49 > > > > D-85049 Ingolstadt > > > > > > > > <http://www.wfi.edu/lsqm> www.wfi.edu/lsqm > > > > > > > > Fon: +49 841 937-1923 > > > > Fax: +49 841 937-1965 > > > > > > > > This e-mail and any attachment is for authorized use by > > the intended > > > > recipient(s) only. It may contain proprietary material, > > confidential > > > > information and/or be subject to legal privilege. It should not > be > > > > copied, disclosed to, retained or used by any other party. > > > > If you are not an intended recipient then please promptly > > delete this > > > > e-mail and any attachment and all copies and inform the sender. > > > > > > > > > > > > > > > >_ > > > > > > > > > > > > > > > > > > > > [[alternative HTML version deleted]] > > > > > > > > > > > > > > > > > > > > __ > > > > r-h...@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-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] [R] Problems building own package (Error: "package has been build before R-2.10.0")
> -Ursprüngliche Nachricht- > Von: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] > Gesendet: Dienstag, 17. August 2010 22:00 > An: Janko Thyson > Cc: r-de...@r-project. org > Betreff: Re: [R] Problems building own package (Error: "package has > been build before R-2.10.0") > > > > On 17.08.2010 20:36, Janko Thyson wrote: > > Dear List, > > > > > > > > Im doing my first baby steps towards developing own R Packages and > ran into > > the following problem: > > First baby step: Do not cross-post on several lists. Sorry. > > R CMD check mypackage works fine (no errors, no warnings) > > > > R CMD build mypackage works fine (no errors, no warnings) > > > > R CMD INSTALL library=C:\R\R-2.11.1\library > > something\mypackage\mypackage_1.0.tar.gz works fine (no errors, no > > warnings) > > > > > > > > However, when I try loading the package in an R-Session (version > 2.11.1) via > > library(mypackage), R complains about the package being build > before > > version R-2.10.0 and tells me to rebuild it. > > > So the R that is in your PATH is < 2.10.x > Change your PATH and add the R version your are actually working > with As I wrote: "My PATH is set up as explained in the R-Admin manual. Also, the only R version stated there is C:\R\R-2.11.1\bin;. > Uwe Ligges > > > > > > > > Could this possibly be due to the fact that I have multiple R > versions > > installed (this also includes the most recent one, though)? > > > > > > > > To provide you with some details: > > > > - Running Windows XP > > > > - All of my R versions are under C:\R (versions 2.9.2, > 2.10.1, > > 2.11.1). > > > > - I installed Rtools (version 2.1.2) to C:\Rtools and > pointed it > > to C:\R (as this was the default) to interact with R (should this > maybe > > have been C:\R\R-2.11.1?). I also installed everything else > necessary to > > build packages (Inno Setup etc.). > > > > - My PATH is set up as explained in R-Admin manual. Also, > the only > > R version stated there is C:\R\R-2.11.1\bin;. > > > > - I updated the DESCRIPTION file and specified all .Rd files > > correctly. > > > > > > > > Any idea what Im doing wrong? > > > > > > > > Thanks a ton, > > > > Janko > > > > > > > >_ > > > > > > > > Janko Thyson > > <mailto:holger.ko...@ku-eichstaett.de> janko.thy...@ku- > eichstaett.de > > > > Catholic University of Eichstätt-Ingolstadt > > Ingolstadt School of Management > > Statistics and Quantitative Methods > > Auf der Schanz 49 > > D-85049 Ingolstadt > > > > <http://www.wfi.edu/lsqm> www.wfi.edu/lsqm > > > > Fon: +49 841 937-1923 > > Fax: +49 841 937-1965 > > > > This e-mail and any attachment is for authorized use by the intended > > recipient(s) only. It may contain proprietary material, confidential > > information and/or be subject to legal privilege. It should not be > > copied, disclosed to, retained or used by any other party. > > If you are not an intended recipient then please promptly delete this > > e-mail and any attachment and all copies and inform the sender. > > > > > > > >_ > > > > > > > > > > [[alternative HTML version deleted]] > > > > > > > > > > __ > > r-h...@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-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Problems building own package (Error: "package has been build before R-2.10.0")
Dear List, Im doing my first baby steps towards developing own R Packages and ran into the following problem: R CMD check mypackage works fine (no errors, no warnings) R CMD build mypackage works fine (no errors, no warnings) R CMD INSTALL library=C:\R\R-2.11.1\library something\mypackage\mypackage_1.0.tar.gz works fine (no errors, no warnings) However, when I try loading the package in an R-Session (version 2.11.1) via library(mypackage), R complains about the package being build before version R-2.10.0 and tells me to rebuild it. Could this possibly be due to the fact that I have multiple R versions installed (this also includes the most recent one, though)? To provide you with some details: - Running Windows XP - All of my R versions are under C:\R (versions 2.9.2, 2.10.1, 2.11.1). - I installed Rtools (version 2.1.2) to C:\Rtools and pointed it to C:\R (as this was the default) to interact with R (should this maybe have been C:\R\R-2.11.1?). I also installed everything else necessary to build packages (Inno Setup etc.). - My PATH is set up as explained in R-Admin manual. Also, the only R version stated there is C:\R\R-2.11.1\bin;. - I updated the DESCRIPTION file and specified all .Rd files correctly. Any idea what Im doing wrong? Thanks a ton, Janko _ Janko Thyson <mailto:holger.ko...@ku-eichstaett.de> janko.thy...@ku-eichstaett.de Catholic University of Eichstätt-Ingolstadt Ingolstadt School of Management Statistics and Quantitative Methods Auf der Schanz 49 D-85049 Ingolstadt <http://www.wfi.edu/lsqm> www.wfi.edu/lsqm Fon: +49 841 937-1923 Fax: +49 841 937-1965 This e-mail and any attachment is for authorized use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. _ [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel