Displaying 1 result from an estimated 1 matches for "evryday".
Did you mean:
everyday
2002 Apr 09
6
matrix dimension and for loop
Dear all,
My questions are that if I have
> x<-rnorm(50)
> dim(x)<-c(10,5)
> y=1:5
> Z<-matrix(0,NROW(x),NROW(y))
> for (j in 1:NROW(y)) Z[,j]<-x[,j]*y[j]
1. Is there any other way to write this without 'for'
loop?
2. and if I don't know the dimension of x, which could
be only 1 column, how could I write the command
without using if (NCOL(x)==1), or