You can use following script....I think


#create a vector of random numbers on which to test script

v<-sample(1:3,size=90,replace=TRUE)

#creates two matrixes out of vector v which can be assigned to M to test
script
M2<-matrix(v,ncol=2)
M3<-matrix(v,ncol=3)

M<-   #Assign you're matrix or a testmatrix to M and run script



result<-numeric()
imaks<-length(M[,1])
jmaks<-length(unique(M)[,1])

for (i in 1:imaks){

for (j in 1:jmaks){
if (sum(M[i,]==unique(M)[j,])==length(M[1,]))  {
result[i]<-j
}
}
}

result




## The script uses loops so its not efficient - in other words its slow and
might be too slow for larger matrixes.

BR

Jesper
        
        


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Creating-vectors-tp2321440p2323090.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to