[R] assign a constant to a different column for each row

uaca@alumni.uv.es uaca at alumni.uv.es
Mon Oct 27 17:42:36 CET 2003


Hi all

I want to assign a constant to a different column for each row

eg:

m[1,2] <- 0;
m[2,3] <- 0;
m[3,1] <- 0;
m[4,2] <- 0;
m[5,1] <- 0;
...

etc...
          
i've tried apply/tapply with no luck

and also the following

coefs <- rtt.abs[,5:8];
coefs.i <- coefs[] == 1;
coefs[coefs.i] <- 0;

wich results in

"matrix subscripts not allowed in replacement" 

error message, for wich I have not found any workaround

a trivial for() loop is not fast enough

any help would be greatly appreciated, (maybe a gun too) I'm disperated :-\

Thanks in advance

	Ulisses


                Debian GNU/Linux: a dream come true
-----------------------------------------------------------------------------
"Computers are useless. They can only give answers."            Pablo Picasso

--->	Visita http://www.valux.org/ para saber acerca de la	<---
--->	Asociación Valenciana de Usuarios de Linux		<---




More information about the R-help mailing list