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

jorgusch hackl.schorsch at web.de
Fri Nov 13 22:26:23 CET 2009


Hi,

splitting is a good idea..it kills a loop...I keep forgetting this.
I have to try out a bit, whether it covers it all, I'll let you know but
thanks for a start.

It is not really analysing, but exploring the data. I have some plots with
sevendigits points and some things are weird and I try to find, why there
are weird. Patterns etc.
Your post helps for sure, as I will have to go through the data with various
tools.

Thanks!


jholtman wrote:
> 
> # no data given, so try something like this:
> # split by scanID and then check for dups
> dups <- lapply(split(x$ListingPrice, x$ScanID,), function(.price){
>     # return sum of duplicated; non-zero => duplicated prices
>     sum(duplicated(.price))
> })
> 
> 
> On Thu, Nov 12, 2009 at 12:11 PM, jorgusch <hackl.schorsch at web.de> wrote:
>>
>> 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.
>>
>> ______________________________________________
>> R-help at 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.
>>
> 
> 
> 
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
> 
> What is the problem that you are trying to solve?
> 
> ______________________________________________
> R-help at 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.
> 
> 

-- 
View this message in context: http://old.nabble.com/vector-based-command-for-equal-values---if-too-slow-tp26322526p26343798.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list