0

my data looks something like this:

Point   CODE  Area 
1.001   231   10
1.001   231   20
1.002   211   45
1.002   211   20
1.002   211   30
1.002   231   20
1.002   231   20
1.002   231   110

Where each Point is a unique value, each CODE is Unique, and Area is the area associated with each CODE.

I'm trying to merge the values in the case where the Point values are the same AND the Code values are the same, then the Areas under each CODE are added together, and the final resulting table looks like the following:

Point   CODE    TotArea
1.001   231     30
1.002   211     95
1.002   231     150

Any suggestions?

My file sizes are massive ( > 1 million rows), and I'm also new to R.

erasmortg
  • 3,246
  • 1
  • 17
  • 34

1 Answers1

1

You can use the package dplyr:

library(dplyr)

data %>% group_by(Point,CODE) %>%
         summarise(TotArea = sum(Area))
jeremycg
  • 24,657
  • 5
  • 63
  • 74