[R] vector based command for equal values - if too slow

jorgusch hackl.schorsch at web.de
Thu Nov 12 18:11:48 CET 2009


Hi,
I have a big set of data with price lists in different periods. I want to
check whether there are equal prices and if so, start a loop to look closer
into it. However, my solution so far is based on a loop and I cannot think
of a vector based approach...any ideas?

# Counting vectors
equali<-0
noequali<-0
resultsi<-c()

#splitting the data set
    scanid<-xall$ScanID
    Uscanid<-unique(scanid)
    ULscanid<-length(Uscanid)

    for(q in 1:ULscanid){
        qscanid<-Uscanid[q]
        x<-subset(xall, ScanID==qscanid)

## __Testing whether there are any equal prices in this ScanID
     #-number of prices
        xLprice<-length(x$ListingPrice)
            if (xLprice > 1){

         #-creating list of unique prices
                xUprice<-unique(x$ListingPrice)
                xULprice<-length(xUprice)

#!!!!!!!!!!!!!!!
#- Check whether the price are all unique or not...this takes time....

	              if (xULprice==xLprice){
	                  noequali<-noequali+1
                     }else{
 		            equali<-equali+1
                     }


          }
    }#-end ScanId

Well, any ideas for a vector based solution would be a great help! It would
help the environment for sure, otherwise my machine has to run over night
;-)

By the way, I all the efficient guys here are somehowe environmentalists -
no offense!
-- 
View this message in context: http://old.nabble.com/vector-based-command-for-equal-values---if-too-slow-tp26322526p26322526.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list