Re: [R] replacement functions for subsets

2013-07-10 Thread Harry Mamaysky
; > twoTimes(p[1:2]) <- c(100,102) > Calling twoTimes<-: x= 1:2 > > p > [1] 50 51 3 4 5 > > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > > > -Original Message- > > From: r-help-boun...@r-project.org [mailto:r-help

Re: [R] replacement functions for subsets

2013-07-10 Thread William Dunlap
ling twoTimes<-: x= 1:2 > p [1] 50 51 3 4 5 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Harry Mamaysky > Sent: Wednesday, July 10, 2

Re: [R] replacement functions for subsets

2013-07-10 Thread Harry Mamaysky
So how would I get the following to work? > aa<-1 > aa [1] 1 > 'foo<-' <- function(x,value) x<-value > foo(aa)<-1:10 > aa [1] 1 2 3 4 5 6 7 8 9 10 > # This doesn't work: > foo(aa)[4:5] <- c(101,102) Error in foo(aa)[4:5] <- c(101, 102) : could not find function "foo" > # What I would like

Re: [R] replacement functions for subsets

2013-07-10 Thread Bert Gunter
I think the OP may perhaps want to define a method for "[<-" . e.g. try: methods("[<-") If this is not it ... ?? Cheers, Bert On Wed, Jul 10, 2013 at 12:51 PM, David Winsemius wrote: > > On Jul 10, 2013, at 12:17 PM, Harry Mamaysky wrote: > >> As I understand it rownames(aa) returns a copy of

Re: [R] replacement functions for subsets

2013-07-10 Thread David Winsemius
On Jul 10, 2013, at 12:17 PM, Harry Mamaysky wrote: > As I understand it rownames(aa) returns a copy of an attribute of aa. So > changing the value of this vector should make the change to the copy of the > row.names attribute. I would then have to set the original row.names equal to > this co

Re: [R] replacement functions for subsets

2013-07-10 Thread Harry Mamaysky
As I understand it rownames(aa) returns a copy of an attribute of aa. So changing the value of this vector should make the change to the copy of the row.names attribute. I would then have to set the original row.names equal to this copy to effect the change. So my question is why "rownames(aa)[

Re: [R] replacement functions for subsets

2013-07-10 Thread David Winsemius
On Jul 10, 2013, at 11:47 AM, Harry Mamaysky wrote: > I know how to define replacement functions in R (i.e. ‘foo<-‘ <- > function(x,value) x<-value, etc.), but how do you define replacement > functions that operate on subsets of arrays (i.e. how do you pass an index > into foo)? > For example,