[R] tr: Aggregate values in one dataframe into a list of vectors of different sieze

sartene at voila.fr sartene at voila.fr
Mon Oct 21 17:41:53 CEST 2013


I just found out what I was looking for, aggregate did the trick:
AggregatedList <- aggregate(data = Sample, Value ~ Name, list)

Hope this will help someone else!


Sartene Bel

> Message du 21/10/13 à 16h29
> De : sartene at voila.fr
> A : r-help at r-project.org
> Copie à : 
> Objet : Aggregate values in one dataframe into a list of vectors of different sieze
> 
> Hi everyone,
> 
> I have a data frame that is quite huge (dozens of millions of lines).
> 
> It looks like this :
> 
> Name      Value
> Name1    156
> Name2    458963
> Name3    758
> ...
> Name143 89325
> Name1     4678
> Name42   766
> Name144 777
> ...
> Name2     46767
> ...
> 
> Each name and and value has no predefined length and may be repeated any number of times.
> 
> My goal is to have a list (aggregating the numbers relative to each name, so to obtain a data frame which looks like this:
> Name     Values
> Name1   156, 4678,...
> Name2   458963, 46767...
> ...
> 
> Creating the unique names in the first column is easy via the unique function, but I did not find any way to regroup in matching vectors the different values 
aggregated for each name, of to directly create a data frame like I want.
> 
> The ultimate goal is to use the values in the vectors to do some statistics (means, etc.), but that is another matter for later!
> 
> Thanks for your help.
> 
> 
> Sartene Bel
> ___________________________________________________________
> Les prévisions météo pour aujourd'hui, demain et jusqu'à 8 jours ! Voila.fr http://meteo.voila.fr/
___________________________________________________________
Les prévisions météo pour aujourd'hui, demain et jusqu'à 8 jours ! Voila.fr http://meteo.voila.fr/



More information about the R-help mailing list