[R] scatterplot of 100000 points and pdf file format

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Thu Nov 25 03:12:20 CET 2004


On 25-Nov-04 Austin, Matt wrote:
>> -----Original Message-----
>> From: r-help-bounces at stat.math.ethz.ch
>> [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of
>> Ted.Harding at nessie.mcc.ac.uk
>> Sent: Wednesday, November 24, 2004 16:37 PM
>> To: R Help Mailing List
>> Subject: RE: [R] scatterplot of 100000 points and pdf file format
>> 
>> 
>> On 24-Nov-04 Prof Brian Ripley wrote:
>> > On Wed, 24 Nov 2004 Ted.Harding at nessie.mcc.ac.uk wrote:
>> > 
>> >> 1. Multiply the data by some factor and then round the
>> >>   results to an integer (to avoid problems in step 2).
>> >>   Factor chosen so that the result of (4) below is
>> >>   satisfactory.
>> >>
>> >> 2. Eliminate duplicates in the result of (1).
>> >>
>> >> 3. Divide by the factor you used in (1).
>> >>
>> >> 4. Plot the result; save plot to PDF.
>> >>
>> >> As to how to do it in R: the critical step is (2),
>> >> which with so many points could be very heavy unless
>> >> done by a well-chosen procedure. I'm not expert enough
>> >> to advise about that, but no doubt others are.
>> > 
>> > unique will eat that for breakfast
>> > 
>> >> x <- runif(1e6)
>> >> system.time(xx <- unique(round(x, 4)))
>> > [1] 0.55 0.09 0.64 0.00 0.00
>> >> length(xx)
>> > [1] 10001
>> 
>> 'unique' will eat x for breakfast, indeed, but will have some
>> trouble chewing (x,y).
>> 
> 
> 
>>  xx <- data.frame(x=round(runif(1000000),4),
>>  y=round(runif(1000000),4))
>>  system.time(xx2 <- unique(xx))
> [1] 14.23  0.06 14.34    NA    NA
> 
> The time does not seem too bad, depending on how many times it
> has to be performed.
> --Matt

Interesting! Let's see:

Starting again,

  X<-round(rnorm(1e6),3);Y<-round(rnorm(1e6),3)
  XY<-cbind(X,Y)
  system.time(unique(XY))
  [1] 288.22   3.00 291.38   0.00   0.00

  XY<-data.frame(x=X,y=Y)
  system.time(unique(XY))
  [1] 72.38  0.84 74.44  0.00  0.00


Data Frames Are Fast Food!!!

Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 25-Nov-04                                       Time: 02:12:20
------------------------------ XFMail ------------------------------




More information about the R-help mailing list