Hello,
Try the following.
dat <- read.csv(text = "
Regime, Industry, Cost
10, 01, 370
11, 01, 400
10, 02, 200
10, 01, 500
11, 02, 60
10, 02, 30
")
dat
res <- aggregate(Cost ~ Industry + Regime, data = dat, sum)
res <- res[order(res$Industry), ]
res
And see the help page ?aggregate
Hope this
o Letizia
> Cc: R Help
> Subject: Re: [R] Data aggregation
>
> ?tapply
>
> You should have encountered this already in most basic R tutorials.
> Have you gone through any? If not, you should. In particular,you need to
> learn about R's basic data structures (e.g. data f
?tapply
You should have encountered this already in most basic R tutorials.
Have you gone through any? If not, you should. In particular,you need
to learn about R's basic data structures (e.g. data frames).
Alternatively, the dplyr package has many elegant tools for this sort
of thing. You might
Dear All:
I have a data frame with 3 columns: "Regime", "Industry", and "Cost".
I want to sum the value of "Cost" for each industry and "Regime".
Example:
The data frame is:
Regime, Industry, Cost
10, 01, 370
11, 01, 400
10, 02, 200
10, 01, 500
11, 02, 60
10, 02, 30
I want the following output:
0
Hi all,
table() did the trick, and very efficiently, too! Thanks for the
advice,
Dave
On Thu, Jul 28, 2011 at 5:39 PM, David Winsemius wrote:
>
> On Jul 28, 2011, at 4:24 PM, David Warren wrote:
>
> Hi all,
>>
>>I'm working with a sizable dataset that I'd like to summarize, but I
>>
On Jul 28, 2011, at 4:24 PM, David Warren wrote:
Hi all,
I'm working with a sizable dataset that I'd like to summarize,
but I
can't find a tool or function that will do quite what I'd like.
Basically,
I'd like to summarize the data by fully crossing three variables and
getting
a co
$ y : Factor w/ 2 levels "i","ii": 1 1 1 2 2 2
$ Freq: int 0 1 0 2 0 1
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of David Warren
> Se
You don't offer a reproducible example, but what do you need that table()
doesn't provide?
testdata <- data.frame(A=factor(sample(1:3, 20)), B=factor(sample(1:3,
20)), C=factor(sample(1:3, 20)))
table(testdata)
Sarah
On Thu, Jul 28, 2011 at 4:24 PM, David Warren
wrote:
> Hi all,
>
> I'm wor
Hi all,
I'm working with a sizable dataset that I'd like to summarize, but I
can't find a tool or function that will do quite what I'd like. Basically,
I'd like to summarize the data by fully crossing three variables and getting
a count of the number of observations for every level of that 3
9 matches
Mail list logo