I have a data frame in R like this:
  ID   REGION  FACTOR  
  01    north    1
  02    north    1
  03    north    0
  04    south    1
  05    south    1
  06    south    1
  07    south    0
  08    south    0
I want to create a column with the number of lines by 'region' and filtered by some factor (factor==1).
I know how to compute the values, but I could not find the functions to have this output:
  ID   REGION  FACTOR  COUNT
  01    north     1      2
  02    north     1      2
  03    north     0      2
  04    south     1      3
  05    south     1      3
  06    south     1      3
  07    south     0      3 
  08    south     0      3
Could someone help me?