0
I have a data frame with more than 1 million lines and I need to count the number of occurrences of a variable. However, the value found has to be inserted in a new "Qtde" column and the values have to start at the minimum occurrence value (1) up to the total N value. It is a little complicated to explain, so I leave this link https://docs.google.com/spreadsheets/d/15TjkKfFm7o0PPqvOWJPMGCkZCKV1O0JmKpxnvWwRv7g/edit?usp=sharing a part of the data frame so that you can visualize and understand better. Remembering that, I can not summarize the data frame. Type, find different values of the variable "key_find" by the amount of times it appears and yes, keep the amount of original lines in the file and add the value of quantity 1 to the limit found in the new variable, column "Qtde"
This is the code I wrote, but it’s not working:
Count_Qualific <- Count_Qualific %>%
mutate(qtde = for (i in seq_along(key_find)) {
if_else(key_find[i] = key_find[i - 1], 1 + qtde[i], qtde[i])
})
Exit:
Erro: '=' inesperado in:
" mutate(qtde = for (i in seq_along(key_find)) {
if_else(key_find[i] ="
> })
Erro: '}' inesperado in " }"
>
We complicate things... Thank you very much Rui Barradas Help! Problem solved successfully!
– Maximiliano Prado