[R] Re : ReferenceClasses examples {method}

Marc Carpentier marc.carpentier at ymail.com
Fri Jan 28 18:35:04 CET 2011


Right. Shame on me : Friday's tiredness ; I don't know why I stuck on that.
Please just consider the main topic of my message, regarding the example of 
ReferenceClasses (supposing it's appropriate) and sorry for the subsequent 
question...


----- Message d'origine ----

De : David Winsemius <dwinsemius at comcast.net>
À : Marc Carpentier <marc.carpentier at ymail.com>
Cc : r-help at r-project.org
Envoyé le : Ven 28 janvier 2011, 17h 39min 59s
Objet : Re: [R] ReferenceClasses examples {method}


On Jan 28, 2011, at 11:05 AM, Marc Carpentier wrote:

> Dear help, dear John Chambers,
> I'm trying to learn OOP-possibilities in R and I was going through the
> documentation 'ReferenceClasses {methods}'. (great work, by the way...)
> Reading associated Examples, something bothers me : it seems to me that there
> are errors in 'edit' and 'undo' methods. I think that :
> - 'undo' should update 'edits' field with :
> length(edits) <<- length(edits) - 1 #(and not - 2)
> - and for coherence, 'edit' should store modifications in an 'append'-style :
> edits <<- c(edits,list(backup)) #as opposed to c(list(backup),edits)
> 
> I hope I'm not wrong.
> 
> As a complementary question, suppose one kept 'c(edits,list(backup))', does
> anyone know how todiscard first element(s) of a list? For a vector :
> vedits<<-vedits[-1]
> But lists can't be selected that way ( edits<<- edits [[-1]] #wrong )

You are confusing "[" and "[["

> ll <- list(a=1,b=2,cc=3)
> ll[-1]
$b
[1] 2

$cc
[1] 3
> 
--
David Winsemius, MD
West Hartford, CT






More information about the R-help mailing list