Re: [Rd] [R] R-2.4.0 and MS Vista OS - installing packages

2006-10-21 Thread Uwe Ligges
[moved to R-devel]

Thanks for the report.
It would be interesting to know if the package installation fails 
because of chm files or because you are trying to install stuff into a 
directory with insufficient permissions even for other files.
If we are supposed packages in a different way for Vista, it would be 
nice to be able (i.e. knowing what to do) to apply relevant changes 
before the next major release (R-2.5.0?).

Best,
Uwe


Charles Annis, P.E. wrote:
> Problem solved!
> 
> Thanks to all and especially Clint Bowman and Uwe Ligges who pointed to the
> fly in the ointment, viz. Vista's "User Account Control," UAC.  
> 
> To allow installation of R packages, you must open the Vista Control Panel
> and choose Windows Security Center.  Then turn the UAC off.  This will
> require a restart of the computer.  After the computer restarts and you
> summon R, packages can be installed from CRAN in the usual way.  After
> installation you can reassert the UAC which also requires a computer
> restart.  Vista starts up about 5X faster than my 3 year old Windows XP
> machine, so the restarts are not onerous.
> 
> Many thanks to you all!
> 
> Charles Annis, P.E.
> 
> [EMAIL PROTECTED]
> phone: 561-352-9699
> eFax:  614-455-3265
> http://www.StatisticalEngineering.com
>  
> 
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Clint Bowman
> Sent: Friday, October 20, 2006 4:59 PM
> To: Charles Annis, P.E.
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] R-2.4.0 and MS Vista OS - installing packages
> 
> This week's eweek has an article on Vista's security and system
> administration--I'm guessing (a Linux user guess) that you are running
> afoul of Vista's User Account Control feature.
> 
> Clint Bowman  INTERNET:   [EMAIL PROTECTED]
> Air Dispersion ModelerINTERNET:   [EMAIL PROTECTED]
> Air Quality Program   VOICE:  (360) 407-6815
> Department of Ecology FAX:(360) 407-7534
> 
>   USPS:   PO Box 47600, Olympia, WA 98504-7600
>   Parcels:300 Desmond Drive, Lacey, WA 98503-1274
> 
> On Fri, 20 Oct 2006, Charles Annis, P.E. wrote:
> 
>> I have installed Microsoft Vista Release Candidate 1, and R-2.4.0, on a 4
>> year old DELL box with a 2.26 GHz P4 and 1 gig.  It was a clean install –
> R
>> is the only non-MS program running.
>>
>> I cannot install packages from CRAN, nor from local zipped files.  (I have
>> R-2.4.0 installed on a Windows XP machine and have had no problems so the
>> difficulty seems to be Vista not R, however they aren't playing together
>> nicely as they should.)
>>
>> The CRAN installation of R-2.4.0 on the Vista machine was without
> incident,
>> but after downloading the zipped packages from CRAN I get this error
>> message:
>>
>>
>>> utils:::menuInstallPkgs()
>> trying URL
>>
> 'http://cran.us.r-project.org/bin/windows/contrib/2.4/RColorBrewer_0.2-3.zip
>> '
>> Content type 'application/zip' length 39787 bytes
>> opened URL
>> downloaded 38Kb
>>
>> Error in zip.unpack(pkg, tmpDir) : cannot open file 'C:/Program
>> Files/R/R-2.4.0/library/file6fc97ac2/RColorBrewer/chtml/RColorBrewer.chm'
>> Any help would be appreciated.  Thanks.
>>
>>
>> Charles Annis, P.E.
>>
>> [EMAIL PROTECTED]
>> phone: 561-352-9699
>> eFax:  614-455-3265
>> http://www.StatisticalEngineering.com
>>  
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> __
> R-help@stat.math.ethz.ch 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] sort function (PR#9309)

2006-10-21 Thread Ulrike Grömping
What Luis probably means can be reproduced by this little example:

a<-5:1
b<-t(t(a))
b
sort(b)

In R 2.2.1 (Windows XP), sort(b) is a matrix with 1 column, like b. In R 2.4.0 
(and presumably already 2.3.1), sort(b) is no longer a matrix but a vector (and 
displayed as a row).

Regards, Ulrike

-- Original Message ---
From: Uwe Ligges <[EMAIL PROTECTED]> 
To: [EMAIL PROTECTED] 
Cc: r-devel@stat.math.ethz.ch 
Sent: Fri, 20 Oct 2006 23:09:02 +0200 
Subject: Re: [Rd] sort function (PR#9309)

> [EMAIL PROTECTED] wrote: 
> > Full_Name: Luis Frank 
> > Version: 2.3.1 
> > OS: 
> > Submission from: (NULL) (168.96.156.79) 
> > 
> > 
> > Hallo! 
> > 
> > In version 2.3.1 tha sort function applied to a vector trasposes it. This 
> > does 
> > not happen in earlier versions. As a consequence, old programms don´t work 
> > in 
> > newer versions. 
> > 
> > Thanks! 
> > Luis 
> 
> Please read the FAQ how to report bugs. 
> 
> 1. You are using an outdated version of R, please only report bugs of 
> recent R versions. 
> 2. You have not given your OS. 
> 3. You have not given an example that reproduces the bug, my try does 
> not transpose anything: 
>  x <- 5:1 
>  x 
>  sort(x) 
> 
> So, please  
> 
> Uwe Ligges 
> 
> > __ 
> > 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 
--- End of Original Message ---

 

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] sort function (PR#9309)

2006-10-21 Thread Uwe Ligges


Ulrike Grömping wrote:
> What Luis probably means can be reproduced by this little example:
> 
> a<-5:1
> b<-t(t(a))
> b
> sort(b)
> 
> In R 2.2.1 (Windows XP), sort(b) is a matrix with 1 column, like b. In R 
> 2.4.0 (and presumably already 2.3.1), sort(b) is no longer a matrix but a 
> vector (and displayed as a row).

I see. This is not a bug. It *was* a bug in R < 2.3.0 and has been 
fixed. From NEWS:

 o   sort() now does not return inappropriate attributes such as
 "dim" and "tsp": it only returns names.

You cannot expect sort to do anything meaningful when applied to 
matrices or arrays other than returning a sorted vector of the elements, 
and that is what sort does nowadays.

Best,
Uwe Ligges


> Regards, Ulrike
> 
> -- Original Message ---
> From: Uwe Ligges <[EMAIL PROTECTED]> 
> To: [EMAIL PROTECTED] 
> Cc: r-devel@stat.math.ethz.ch 
> Sent: Fri, 20 Oct 2006 23:09:02 +0200 
> Subject: Re: [Rd] sort function (PR#9309)
> 
>> [EMAIL PROTECTED] wrote: 
>>> Full_Name: Luis Frank 
>>> Version: 2.3.1 
>>> OS: 
>>> Submission from: (NULL) (168.96.156.79) 
>>>
>>>
>>> Hallo! 
>>>
>>> In version 2.3.1 tha sort function applied to a vector trasposes it. This 
>>> does 
>>> not happen in earlier versions. As a consequence, old programms don´t work 
>>> in 
>>> newer versions. 
>>>
>>> Thanks! 
>>> Luis 
>> Please read the FAQ how to report bugs. 
>>
>> 1. You are using an outdated version of R, please only report bugs of 
>> recent R versions. 
>> 2. You have not given your OS. 
>> 3. You have not given an example that reproduces the bug, my try does 
>> not transpose anything: 
>>  x <- 5:1 
>>  x 
>>  sort(x) 
>>
>> So, please  
>>
>> Uwe Ligges 
>>
>>> __ 
>>> 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 
> --- End of Original Message ---
> 
>  
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] [R] multithreading calling from the rpy Python package

2006-10-21 Thread Andrew Piskorski
On Fri, Oct 20, 2006 at 04:11:11PM +0200,  Ren? J.V. Bertin  wrote:
> Since Python has been mentioned in this context: Could not Python's
> threading model and implementation serve as a guideline?

Why would you want to do that?  Does that model have some particular
synergy with R's design or current limitations?  (From later posts, I
suspect that the answer to that is "yes".)

I'm curious, what is the current state of the R implementation's
support for thread-safety, re-entrant code, and concurrency?  What
issues in the code block improvement?  Is there a summary anywhere
more recent than the the info here?:

  http://developer.r-project.org/RThreads/index.html

And perhaps most importantly, what are the main users or use cases
driving (or likely to drive in the future) improved multi-threading
support?  Who really wants it, and why?

It would certainly be nice to make R completely thread-safe (and
ideally, fully reentrant), so that it could be easily embedded into a
multi-threaded program.  But, that sounds like a non-mainstream use of
R, and thus unlikely to motivate most of the R core developers.

R also already has about 8 different packages for doing parallel
programming across multiple machines using MPI, PVM, or etc.  I wonder
to what degree these obviate the need for multi-threaded R.
(Certainly not 100%, as most of those approaches will have vastly
worse latency than multi-threading.  But I wonder how much of the same
use cases they cover, 20%, or 80%?)

There's also the broader question of how or whether multi-threading
support would help, hinder, or otherwise interact with other potential
cool changes to R.  E.g., a high-performance byte-code interpreter, or
Lisp-like macros.

Any large single threaded application like R is going to have its own
particular obstacles to making the code thread-safe, and more to
making it reentrant and adding good multi-threading support of one
flavor or another.

I don't know what the particular obstacles for R are.  But if I was
looking for a GENERAL example of implementing a multi-threaded
interpreter, I certainly wouldn't choose Python.

Neither Python nor Ruby have real multi-threading, and are only
thread-safe via some sort of global lock.  (Only one thread can ever
run at a time, no matter how many CPUs your machine has.)  Perl
probably does support real multi-threading, but people say it hasn't
had much real world use.  Tcl has excellent multi-threading support,
using independent interpreters on top of OS threads (POSIX or Win32),
and has been in heavy use for many years.  I don't know about Lua,
JavaScript, the eleventy dozen different Scheme implementations,
etc. etc.

There are lots of different models for threading and concurrency.
OS-threads vs. user-mode threads is just one variable in the choice
space.  There's also message passing vs. shared memory, threads
vs. event-based programming, default shared-everything vs. default
shared-nothing, etc. etc.

In my experience, Tcl's "apartment model" for multi-threading is quite
nice to work with.  With it, you program each Tcl interpreter as if it
was a stand-alone shared-nothing process, which communicates with
other Tcl interpreters only through explicit shared memory and message
passing APIs.  Underneath, the C code sees the true shared-everything
threading implementation, but also has APIs to make working with it
easier.

(Note that Tcl implements that on top of POSIX and Win32 threads, but
you could implement the exact same script-level model on top of
inter-process shared memory.  Only the C code underneath would see any
difference.)

I have never really used any other threading model extensively, so I
can't do a proper hands-on compare and contrast.  However, my
suspicion is that "shared nothing by default" models (like Tcl's
threading) are the better way to go, rather than "shared everything by
default" (like POSIX threads).  The Erlang and Mozart/Oz folks both
seem to think so, etc.

-- 
Andrew Piskorski <[EMAIL PROTECTED]>
http://www.piskorski.com/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] default arguments in generics and methods

2006-10-21 Thread John Chambers
You're conflating 3 different things here:  how methods are selected, 
how R treats missing arguments, and how the standardGeneric() call is 
implemented.

Maybe more relevant, if this question is motivated by a practical need, 
you may want to rethink what the generic function does.  "Nonstandard" 
generic functions are called that  for a reason.  The concept behind 
methods in S is that a generic function defines the _function_ or 
purpose of the computation, but it's only the methods that define how 
the purpose is carried out.

Using a nonstandard generic that does some extra computation always 
blurs the concept, and often makes methods harder to write or 
understand.  That you've found it necessary to worry about the subtle 
points in your question is a warning sign.  It's usually worth asking 
whether the place that you call standardGeneric() could in fact _be_ the 
generic, with the other computations moved to a nongeneric wrapper 
function.  Having said that,  when the computations depend on missing 
arguments, the situation may be more complicated.

Anyway, the following relate to your question.

1.  In method selection, the "missing" class is used if the C-level 
equivalent of the test missing(ARG) is TRUE when selection takes place.  
On to point 2.

2.  The R evaluator stores a special object corresponding to missing 
arguments.  Missing arguments are treated by the lazy evaluation rules, 
so the exact contents of the current object of this name in the local 
environment will depend on whether there has been a reference to the 
argument.  The missing(ARG) test remains TRUE when the default 
expression is evaluated but becomes FALSE if a direct assignment of ARG 
takes place (just reporting this, not defending it).

3.  standardGeneric() creates a  new context into which it copies 
bindings for all the objects in the frame of the generic function call, 
but tries to maintain defaults for missing arguments.  If you want to 
see how it works, look at the routine R_execMethod in file 
src/main/eval.c of the R source.

The somewhat unfortunate result of all this can be seen by comparing two 
nonstandard generics:

setGeneric("foo", function(x, y){if(missing(y)) y <- x+1; 
standardGeneric("foo")})

setGeneric("foo2", function(x, y = x+1){if(missing(y)) message(y); 
standardGeneric("foo2")})

The "foo" function will never dispatch a method for c("numeric", 
"missing") because y is assigned directly.  The "foo2" function will 
dispatch such a method though, even though the numerical value of y will 
be the same in message(y).

As may be obvious, the computation is subtle and it might be foolish to 
rely on the details as if they were part of the API.

Parlamis Franklin wrote:
> i believe the following is true but would appreciate confirmation  
> that it is intended behavior and will continue:
>
> if a default argument is employed in the definition of a generic  
> function, and the generic is called with the argument in question  
> (call it 'ARG') missing, then the method for signature (..., ARG =  
> "missing", ...) will be called by 'standardGeneric' whether or not  
> ARG is evaluated in the body of the generic prior to the call to  
> 'standardGeneric';  however, the value assigned to ARG in the method  
> call will depend on whether ARG was evaluated in the body of the  
> generic prior to the call to 'standardGeneric' (with the default  
> value assigned in the case of prior evaluation and no value assigned  
> in the case of no prior evaluation).  furthermore, if ARG is  
> explicitly assigned to in the body of the generic prior to the call  
> to 'standardGeneric', then the method for signature (..., ARG = class 
> (ARG), ...) will be called, with the assigned value of ARG passed to  
> the call.
>
> this behavior is exhibited by the code below:
>
> __
>
> setGeneric("foo", function(x = 1) standardGeneric("foo"),  
> useAsDefault = FALSE)
> setMethod("foo", signature(x = "missing"), function(x = 3) x)
>
> setGeneric("foo2", function(x = 1) {x; standardGeneric("foo2")},  
> useAsDefault = FALSE)
> setMethod("foo2", signature(x = "missing"), function(x = 3) x)
>
> setGeneric("foo3", function(x = 1) {x<-2; standardGeneric("foo3")},  
> useAsDefault = FALSE)
> setMethod("foo3", signature(x = "missing"), function(x = 3) x)
> setMethod("foo3", signature(x = "numeric"), function(x = 3) x^2)
>
> foo() # returns 3
> foo2()# returns 1
> foo3()# returns 4
>
> ___
>
> franklin parlamis
>
> __
> 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] understanding virtual classes and extensions thereof

2006-10-21 Thread John Chambers
IMO, the recommended version is:

setClass("kid2", contains = c("mom", "VIRTUAL"))

because it's the clearest, using the representation argument only for 
defining slots.  Better yet, if your virtual classes don't have any 
slots defined, use setClassUnion() for "mom", with the other classes 
members of the union.

The other versions are mainly to be back-compatible, with "Programming 
with Data" in particular.  They _should_ produce the same result.

As for:

setClass("kid4", contains = "mom")

this is currently a meaningless class: It's not virtual but it has no 
meaningful prototype.  My preference would be a change that makes this a 
virtual class, as the programmer probably intended (maybe with a warning 
for now since it's technically a change in the API).


Parlamis Franklin wrote:
> I am having some trouble creating a hierarchy of virtual classes  
> (akin to the class structure in the 'Matrix' package).  I think they  
> arise from my not understanding the best way to specify virtual  
> subclasses of a virtual class.  please see questions below code.
>
> setClass("mom")
>
> setClass("kid1", representation("mom", "VIRTUAL"))
> setClass("kid2", representation("VIRTUAL"), contains = "mom")
> setClass("kid3"); setIs("kid3", "mom")
>
> (i) Are 'kid1' and 'kid2' equivalent?  I.e., is there any difference  
> between including a superclass as an unnamed argument in the  
> 'representation' call and including it in the 'contains' argument?   
> If not, why does the 'contains' argument exist?
>
> (ii) What is the difference between 'kid1' and 'kid2', on the one  
> hand, and 'kid3', on the other hand?  I see that 'kid1' and 'kid2'  
> have prototypes of class 'S4', while 'kid3' has a prototype of class  
> "NULL".  But I don't really understand the implications of that.  I  
> am using virtual classes mostly to economize on method writing.  Will  
> it matter on any level whether my virtual classes have NULL or S4  
> prototypes?
>
> On a related note, the behavior exhibited below also seems infelicitous
>
> setClass("kid4", contains = "mom")
> new("kid4")  # error in the show method
>
> franklin parlamis
>
> __
> 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] R-2.4.0 and MS Vista OS - installing packages

2006-10-21 Thread Charles Annis, P.E.
I wish I were a more knowledgeable computer weenie, but I'm just an amateur
beta-testing the Vista OS.

Since I could install R easily from CRAN but the packages balked with the
default security settings but installed without incident when I turned the
User Account Control off, I would guess that it's the OS, not R.  

Does the base installation use chm files?

Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-Original Message-
From: Uwe Ligges [mailto:[EMAIL PROTECTED] 
Sent: Saturday, October 21, 2006 7:03 AM
To: [EMAIL PROTECTED]
Cc: 'Clint Bowman'; r-devel@stat.math.ethz.ch
Subject: Re: [R] R-2.4.0 and MS Vista OS - installing packages

[moved to R-devel]

Thanks for the report.
It would be interesting to know if the package installation fails 
because of chm files or because you are trying to install stuff into a 
directory with insufficient permissions even for other files.
If we are supposed packages in a different way for Vista, it would be 
nice to be able (i.e. knowing what to do) to apply relevant changes 
before the next major release (R-2.5.0?).

Best,
Uwe


Charles Annis, P.E. wrote:
> Problem solved!
> 
> Thanks to all and especially Clint Bowman and Uwe Ligges who pointed to
the
> fly in the ointment, viz. Vista's "User Account Control," UAC.  
> 
> To allow installation of R packages, you must open the Vista Control Panel
> and choose Windows Security Center.  Then turn the UAC off.  This will
> require a restart of the computer.  After the computer restarts and you
> summon R, packages can be installed from CRAN in the usual way.  After
> installation you can reassert the UAC which also requires a computer
> restart.  Vista starts up about 5X faster than my 3 year old Windows XP
> machine, so the restarts are not onerous.
> 
> Many thanks to you all!
> 
> Charles Annis, P.E.
> 
> [EMAIL PROTECTED]
> phone: 561-352-9699
> eFax:  614-455-3265
> http://www.StatisticalEngineering.com
>  
> 
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Clint Bowman
> Sent: Friday, October 20, 2006 4:59 PM
> To: Charles Annis, P.E.
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] R-2.4.0 and MS Vista OS - installing packages
> 
> This week's eweek has an article on Vista's security and system
> administration--I'm guessing (a Linux user guess) that you are running
> afoul of Vista's User Account Control feature.
> 
> Clint Bowman  INTERNET:   [EMAIL PROTECTED]
> Air Dispersion ModelerINTERNET:   [EMAIL PROTECTED]
> Air Quality Program   VOICE:  (360) 407-6815
> Department of Ecology FAX:(360) 407-7534
> 
>   USPS:   PO Box 47600, Olympia, WA 98504-7600
>   Parcels:300 Desmond Drive, Lacey, WA 98503-1274
> 
> On Fri, 20 Oct 2006, Charles Annis, P.E. wrote:
> 
>> I have installed Microsoft Vista Release Candidate 1, and R-2.4.0, on a 4
>> year old DELL box with a 2.26 GHz P4 and 1 gig.  It was a clean install -
> R
>> is the only non-MS program running.
>>
>> I cannot install packages from CRAN, nor from local zipped files.  (I
have
>> R-2.4.0 installed on a Windows XP machine and have had no problems so the
>> difficulty seems to be Vista not R, however they aren't playing together
>> nicely as they should.)
>>
>> The CRAN installation of R-2.4.0 on the Vista machine was without
> incident,
>> but after downloading the zipped packages from CRAN I get this error
>> message:
>>
>>
>>> utils:::menuInstallPkgs()
>> trying URL
>>
>
'http://cran.us.r-project.org/bin/windows/contrib/2.4/RColorBrewer_0.2-3.zip
>> '
>> Content type 'application/zip' length 39787 bytes
>> opened URL
>> downloaded 38Kb
>>
>> Error in zip.unpack(pkg, tmpDir) : cannot open file 'C:/Program
>> Files/R/R-2.4.0/library/file6fc97ac2/RColorBrewer/chtml/RColorBrewer.chm'
>> Any help would be appreciated.  Thanks.
>>
>>
>> Charles Annis, P.E.
>>
>> [EMAIL PROTECTED]
>> phone: 561-352-9699
>> eFax:  614-455-3265
>> http://www.StatisticalEngineering.com
>>  
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> __
> R-help@stat.math.ethz.ch 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] understanding virtual classes and extensions thereof

2006-10-21 Thread Parlamis Franklin
thank you John, as always, for your thoughtful responses.  (i've been  
teaching my children to play chess, which probably isn't that  
different an experience ;)  one further comment and a related (maybe)  
bug report.

comment:

setClass("mom")
setClass("kid2", contains = c("mom", "VIRTUAL"))

will give 'kid2' a prototype of class 'S4', whereas

setClass("kid2")
setClassUnion("mom", "kid2")

will give it a 'NULL' prototype.  as i mentioned in the last message,  
i don't know if that matters on any level, but i instinctively prefer  
the 'NULL' prototype.

__

(maybe) bug report:

the existence of an extends relation in the class definition depends  
on the order of the setIs calls.  see code below.

setClass("A")
setClass("AA")
setClass("AAA")
setClass("")
setIs("AA", "A")
setIs("AAA", "AA")
setIs("", "AAA")
getClass("")  # works fine

setClass("B")
setClass("BB")
setClass("BBB")
setIs("BBB", "BB")
setClass("")
setIs("", "BBB")
setIs("BB", "B")
getClass("") # does not show extension of class 'B'
extends("", "B") # does not show extension of class 'B'
attr(completeExtends(getClass("")), "names") # there it is

please note that this behavior does not occur if i only go to depth 3  
on the virtual nesting.

i am working in the global environment, so perhaps this is an issue  
of recaching at some point.

franklin

On Oct 21, 2006, at 4:43 AM, John Chambers wrote:

> IMO, the recommended version is:
>
> setClass("kid2", contains = c("mom", "VIRTUAL"))
>
> because it's the clearest, using the representation argument only  
> for defining slots.  Better yet, if your virtual classes don't have  
> any slots defined, use setClassUnion() for "mom", with the other  
> classes members of the union.
>
> The other versions are mainly to be back-compatible, with  
> "Programming with Data" in particular.  They _should_ produce the  
> same result.
>
> As for:
>
> setClass("kid4", contains = "mom")
>
> this is currently a meaningless class: It's not virtual but it has  
> no meaningful prototype.  My preference would be a change that  
> makes this a virtual class, as the programmer probably intended  
> (maybe with a warning for now since it's technically a change in  
> the API).
>
>
> Parlamis Franklin wrote:
>> I am having some trouble creating a hierarchy of virtual classes   
>> (akin to the class structure in the 'Matrix' package).  I think  
>> they  arise from my not understanding the best way to specify  
>> virtual  subclasses of a virtual class.  please see questions  
>> below code.
>>
>> setClass("mom")
>>
>> setClass("kid1", representation("mom", "VIRTUAL"))
>> setClass("kid2", representation("VIRTUAL"), contains = "mom")
>> setClass("kid3"); setIs("kid3", "mom")
>>
>> (i) Are 'kid1' and 'kid2' equivalent?  I.e., is there any  
>> difference  between including a superclass as an unnamed argument  
>> in the  'representation' call and including it in the 'contains'  
>> argument?   If not, why does the 'contains' argument exist?
>>
>> (ii) What is the difference between 'kid1' and 'kid2', on the one   
>> hand, and 'kid3', on the other hand?  I see that 'kid1' and  
>> 'kid2'  have prototypes of class 'S4', while 'kid3' has a  
>> prototype of class  "NULL".  But I don't really understand the  
>> implications of that.  I  am using virtual classes mostly to  
>> economize on method writing.  Will  it matter on any level whether  
>> my virtual classes have NULL or S4  prototypes?
>>
>> On a related note, the behavior exhibited below also seems  
>> infelicitous
>>
>> setClass("kid4", contains = "mom")
>> new("kid4")  # error in the show method
>>
>> franklin parlamis
>>
>> __
>> 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] understanding virtual classes and extensions thereof

2006-10-21 Thread Martin Morgan


John Chambers <[EMAIL PROTECTED]> writes:

> As for:
>
> setClass("kid4", contains = "mom")
>
> this is currently a meaningless class: It's not virtual but it has no 
> meaningful prototype.  My preference would be a change that makes this a 
> virtual class, as the programmer probably intended (maybe with a warning 
> for now since it's technically a change in the API).

Maybe I misunderstand the statement about making these constructs
virtual, but I want to use 'empty' classes as predicates for method
dispatch etc. I want to be able to continue to do this:

setClass("Kid")
setClass("GoodKid", contains="Kid")
setClass("BadKid", contains="Kid")

setGeneric("deserts",
   function(object, ...) standardGeneric("deserts"))
setMethod("deserts",
  signature(object="GoodKid"),
  function(object, ...) "learn chess with dad!")
setMethod("deserts",
  signature(object="BadKid"),
  function(object, ...) "straight to bed")

I had been silently hoping that VIRTUAL would *not* be the default, so
that in the above example I could instantiate a niether good nor bad
Kid without some artifice.

Martin

> Parlamis Franklin wrote:
>> I am having some trouble creating a hierarchy of virtual classes  
>> (akin to the class structure in the 'Matrix' package).  I think they  
>> arise from my not understanding the best way to specify virtual  
>> subclasses of a virtual class.  please see questions below code.
>>
>> setClass("mom")
>>
>> setClass("kid1", representation("mom", "VIRTUAL"))
>> setClass("kid2", representation("VIRTUAL"), contains = "mom")
>> setClass("kid3"); setIs("kid3", "mom")
>>
>> (i) Are 'kid1' and 'kid2' equivalent?  I.e., is there any difference  
>> between including a superclass as an unnamed argument in the  
>> 'representation' call and including it in the 'contains' argument?   
>> If not, why does the 'contains' argument exist?
>>
>> (ii) What is the difference between 'kid1' and 'kid2', on the one  
>> hand, and 'kid3', on the other hand?  I see that 'kid1' and 'kid2'  
>> have prototypes of class 'S4', while 'kid3' has a prototype of class  
>> "NULL".  But I don't really understand the implications of that.  I  
>> am using virtual classes mostly to economize on method writing.  Will  
>> it matter on any level whether my virtual classes have NULL or S4  
>> prototypes?
>>
>> On a related note, the behavior exhibited below also seems infelicitous
>>
>> setClass("kid4", contains = "mom")
>> new("kid4")  # error in the show method
>>
>> franklin parlamis
>>
>> __
>> 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

-- 
Martin T. Morgan
Bioconductor / Computational Biology
http://bioconductor.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] parse/INSTALL feature request(s)

2006-10-21 Thread Michael Toews
> What would be possible is to do like other preprocessors do, and put
> comments into the source file to indicate the origin of each line:  then
> the parser could tell you the location in the original file, which would
> be a lot more useful.

I think what you are referring to is already nicely implemented (in 
R/src/main/source.c lines 89 to 97), and the errors are correctly shown 
in my example as lines 1222 to 1223. However, these line numbers are 
irrelevant to the original files, as they been concatenated into one 
large file (I think on line 765 of R/src/scripts/INSTALL.in ). This 
single file is loaded into an R environment (on line 790 of INSTALL.in), 
which is also the region where my original error from 'R CMD INSTALL' 
was thrown. The loading is done by the 'tools:::makeLazyLoading' 
function, which loads in the single R-source file into a fresh 
environment for the package.

I'm unsure of why a single R source file is needed in INSTALL (which 
limits the ability to show any offending file names and their line 
numbers). The functions in R/src/library/tools/R/makeLazyLoad.R could 
perhaps be made a bit more versatile to individually read the R source 
files for a package using a 'pattern="\.R$"', and throw an error from 
'sys.source' displaying the file name, and other error messages from 
'parse'. This is simply a feature-request suggestion, but as Gabor 
advised, I should really develop my functions file-by-file.
+mt

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] parse/INSTALL feature request(s)

2006-10-21 Thread Duncan Murdoch
On 10/21/2006 6:36 PM, Michael Toews wrote:
>> What would be possible is to do like other preprocessors do, and put
>> comments into the source file to indicate the origin of each line:  then
>> the parser could tell you the location in the original file, which would
>> be a lot more useful.
> 
> I think what you are referring to is already nicely implemented 

Thank you.

> (in 
> R/src/main/source.c lines 89 to 97), and the errors are correctly shown 
> in my example as lines 1222 to 1223. However, these line numbers are 
> irrelevant to the original files, as they been concatenated into one 
> large file (I think on line 765 of R/src/scripts/INSTALL.in ).

No, that's not what I was referring to.  Preprocessors put lines like

#line 3 "header.h"

into their output so that the compiler can put useful debugging 
information into files when it processes them.  R could do that when it 
concatenates the files, and then tell you the origin of each line, not 
the relatively useless line number from the concatenated file.  (A very 
simple version would add a record like that on every line, and that 
would work with the current error reporting system; a slightly more 
sophisticated version would just put those lines in between each 
concatenated file, and then the error reporting would need to be made 
aware of them.)

  This
> single file is loaded into an R environment (on line 790 of INSTALL.in), 
> which is also the region where my original error from 'R CMD INSTALL' 
> was thrown. The loading is done by the 'tools:::makeLazyLoading' 
> function, which loads in the single R-source file into a fresh 
> environment for the package.
> 
> I'm unsure of why a single R source file is needed in INSTALL (which 
> limits the ability to show any offending file names and their line 
> numbers). The functions in R/src/library/tools/R/makeLazyLoad.R could 
> perhaps be made a bit more versatile to individually read the R source 
> files for a package using a 'pattern="\.R$"', and throw an error from 
> 'sys.source' displaying the file name, and other error messages from 
> 'parse'. This is simply a feature-request suggestion, but as Gabor 
> advised, I should really develop my functions file-by-file.

I'm reasonably hopeful that version 2.5.0 will have more source level 
debugging support in it, at least to the level of the "slightly more 
sophisticated version", and maybe better than that.

If you'd like to help with this, you can see the (currently extremely 
unstable and incomplete) code on the djm-source branch in the 
repository.  No support for "#line" yet.

Duncan Murdoch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel