Le 09/07/10 14:18, Renaud Gaujoux a écrit :
Hi, is there a way to define a method say '$$' that would behave like '$' and allow calls like 'a$$name'? Thanks. Renaud
No. This is not grammatically valid syntax: > parse( text = 'a$$name' ) Erreur dans parse(text = "a$$name") : '$' inattendu(e) dans "a$$" But you can define custom methods for $. setClass( "Foo", representation( n = "integer" ) ) setMethod( "$", "Foo", function(x, name ){ function( ) rnorm( x...@n ) } ) foo <- new( "Foo", n = 10L ) foo$bla( ) Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/aJHNLV : Rmetrics slides |- http://bit.ly/98Uf7u : Rcpp 0.8.1 `- http://bit.ly/c6YnCi : graph gallery collage ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel