[R] shrink a dataframe for plotting

Alexy Khrabrov alexy.khrabrov at gmail.com
Wed Nov 21 11:34:37 CET 2007


On Nov 21, 2007, at 1:24 PM, Thibaut Jombart wrote:

> Alexy Khrabrov wrote:
>
>> I get tables with millions of rows.  For plotting to a screen-size
>> jpg, obviously just about 1000 points are enough.  Instead of feeding
>> plot() the original millions of rows, I'd rather shrink the original
>> dataframe, using some kind of the following interpolation:
>>
>> -- split dataframe into chunks of N rows each, e.g. 1000 rows each
>> -- compute average for each column
>> -- issue one new row of those averages into the shrunk result
>>
>> Is there any existing package to do that in R?  Otherwise, which R
>> idioms are most effective to achieve that?
>>
>> Cheers,
>> Alexy

>> if you want to extract relevant information from such a table,  
>> splitting
> rows in arbitrary chuncks may not solve your problem. Ordinations in
> reduced space are designed for that kind of task, but hierachical
> clustering may also help. See Legendre & Legendre (1998, Numerical
> Ecology, Elsevier) for examples of such methods in Ecology, and the R
> packages ade4, vegan and hclust.

Well, in this case the function is monotonically decreasing, and so  
averages would do fine just to plot the curve.  What I'm after is an  
R way -- preferably functional -- to split a vector into chunks of N  
elements and issue a new vector of the averages of those chunks.

Cheers,
Alexy



More information about the R-help mailing list