0

How can I group-count strings by numbers? I have the following data:

test.df = read.csv(file = "test.csv", header = TRUE)

Content

iso_a2,FID_Consum
DE,1
DE,1
PT,1
PT,1
DE,1
EN,2
EN,2
PT,3
EN,4
GR,5

I would like to add another column which counts how often the iso_a2 value shows up in all rows if FID_equals the number in the row e.g.

iso_a2,FID_Consum,count
DE,1,3
DE,1,3
PT,1,2
PT,1,2
DE,1,3
EN,2,2
EN,2,2
PT,3,1
EN,4,1
GR,5,1
Henrik
  • 65,555
  • 14
  • 143
  • 159
Stücke
  • 868
  • 3
  • 14
  • 41

0 Answers0