0

I'm working on a database with repeated measures, and I need to calculate the sum of a numeric vector by category and remove repetitions.

Category Area
A 30
A 15
A 20
B 45
B 30
C 12
D 18
D 22

And transform to:

Category Area
A 65
B 75
C 12
D 40

How can i get this in R?

1 Answers1

-1

Assuming you have a data.frame called df with columns Category and Area

df2 <- aggregate.data.frame(x = df["Area"], by = df["Category"], FUN = sum)
vasanthcullen
  • 356
  • 2
  • 9