[R] how to aggregate the dataset

Rui Barradas ruipbarradas at sapo.pt
Thu Dec 13 12:43:51 CET 2012


Hello,

maybe something like this?

range <- with(dat, paste0("[", min_price, ",", max_price, "]"))
dat2 <- with(dat, data.frame(product = product, VN = mean_price, range = 
range, price_band = price_band))

Unless it's a printing problem and you really want the range below VN.


Hope this helps,

Rui Barradas

Em 13-12-2012 11:24, Tammy Ma escreveu:
> Really sorry for messing up.
>
> I want to transform:
>
>> product min_price  max_price mean_price country   price_band
>> 11                     34                     50                           40                         VN       0-300
>> 22                    10                      30                            15                         VN               0-300
>
> into
>
>> Into:
>>
>> product       VN               price_band
>>    11                   40         0-300
>>                           [34,50]
>>    22                 15                     0-300
>>                          [10,30]
>
> How Can I do this in r?
>
>
> Kind regards,
> Tammy
>
>
>
>
> From: metal_licaling at live.com
> To: metal_licaling at live.com
> Subject: RE: [R] how to aggregate the dataset
> Date: Thu, 13 Dec 2012 14:22:54 +0300
>
>
>
>
>
> HI,
>
>
> I want it looks like this:
>
>> Into:
>>
>> product       VN               price_band
>>    11                   40         0-300
>>                           [34,50]
>>    22                 15                     0-300
>>                          [10,30]
>>
>> From: metal_licaling at live.com
>> To: r-help at r-project.org
>> Date: Thu, 13 Dec 2012 13:42:35 +0300
>> Subject: [R] how to aggregate the dataset
>>
>>
>> HI,
>>
>>
>>
>> Sorry for messing up..
>>
>> I want to transform the following dataset:
>>
>> product min_price  max_price mean_price country   price_band
>> 11           34           50               40             VN         0-300
>> 22           10           30               15             VN         0-300
>>
>>
>> Into:
>>
>> product     VN               price_band
>>    11                 40         0-300
>>                       [34,50]
>>    22               15                     0-300
>>                       [10,30]
>>
>>
>> How can I do this in r? I have large dataset like this. I want to transform all into that one. Thanks a lot.
>>
>>
>> Kind regards,
>> Tammy
>>
>>
>>
>>   		 	   		
>> 	[[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>   		 	   		   		 	   		
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.




More information about the R-help mailing list