0

I would like to ask how to manipulate panel dataset in R, lets say he have following dataset:

df <- data.frame(
  Country = c("Alb", "Alb", "Alb", "Alb", "Rus", "Rus", "Rus", "Rus", "Uk", "Uk", "Uk", "Uk"),
  Year = c(2010, 2010, 2011, 2011, 2010, 2010, 2011, 2011, 2010, 2010, 2011, 2011),
  Value = c(55, 60, 75, 80, 45, 50, 110, 111, 101, 85, 45, 65)
)
df

what I need to end up with is resamplet dataset that would look like:

Country Year Value
Alb     2010   115
Alb     2011   155
...

I tought about using group_by in dplyr however I do not know how to solve this even thou it should be pretty easy.

Petr
  • 1,606
  • 2
  • 14
  • 39
  • 1
    The `115`, `155` are not in the dataset. In case you need sum, `df %>% group_by(Country, Year) %>% summarise(Value = sum(Value))`, but the resampling titlee is not clear – akrun Dec 24 '19 at 20:26
  • yes `115, 155` are not in dataset it is sum for each countrz in same year – Petr Dec 24 '19 at 20:29
  • ok, then the code above should work – akrun Dec 24 '19 at 20:35

0 Answers0