Yes,

df is your data.frame.

tapply(df$y, df$x, sum)


On 14/02/07, d. sarthi maheshwari <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> Sorry if this is a wrong post in the forum. Please suggest if this is a
> correct forum to discuss R related basic problem.
>
> I wanted to perform the following task by using R:
>
> e.g.
> input data.frame
> x                  y
> ============
> a                10
> b                20
> a                10
> a                10
> b                15
> b                15
> b                20
>
> In o/p i need
>
> x            y
> =========
> a           30
> b           70
>
> Currently i am storing the data.frame as a database table by using
> sqlSave.
> Then I am retrieving the data using sqlQuery command. In the query I am
> using Group by function of SQL.
>
> is there any smarter way to this in R?
>
>
> --
> thanks
> Sar
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] 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.
>



-- 
Henrique Dallazuanna
Curitiba-ParanĂ¡
Brasil

        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.

Reply via email to