[R] Incremental operator

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Aug 18 23:29:06 CEST 2004


What is gliexp?  str(gliexp) would have been useful information to give.

Assuming it is an R matrix, the rownames are _names_, not numbers.
Surely in all languages with for loops it is bad idea to manipulate
the loop index inside the loop, but you definitely cannot do
arithmetic on character strings.

R does have debugging facilities and it would be a good idea to get
used to them.

options(error=dump.frames)
... some work ....
debugger()
 choose an environment
 i -- will tell you what it is.

On Wed, 18 Aug 2004, S Peri wrote:

>  I am trying to get the LocusID numbers from my affy
> expression matrix.  
> 
> I instantiated rownames function to get an object with
> all the probe IDs.
> 
> > where.affy.at <- rownames(gliexp)
> 
> Now I wanted to get another object with the LocusIDs
> in it like the following.  However, I get the
> following error. How come i = i +1 is not considered
> as incrementation here. I know there is some trouble
> in defining. I come from Python background so I am
> stuck. Could any one help me please. 
> 
> 
> >for (i in where.affy.at){
> +   gene.locusid.affy <- get(i,env= hgu95av2LOCUSID)
> + i = i + 1
> + gene.locusid.affy
> + }
> Error in i + 1 : non-numeric argument to binary
> operator

-- 
Brian D. Ripley,                  ripley at 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, UK                Fax:  +44 1865 272595




More information about the R-help mailing list