A - Adding values with one condition

Asked

Viewed 102 times

-3

Good morning !

I have the DF below, I need to add the values of the accounts (columns with numbers) SEMESTER 1 with the 2 (if you have), by CNPJ and YEAR. Thus, I will have the total values of the YEAR issued by the CNPJ.

inserir a descrição da imagem aqui

I’m trying to use tidyverse to group the values, but I think I’m using the wrong logic and it’s not working.

From now on, thank you.

Note: There are 156 columns of accounts (those that only have numbers).

1 answer

0


It was very simple

I was able to solve using the function

Aggregate()

Became:

Balancete <- aggregate(Balanceteo,                                                  
by = list(Balancete$CNPJ, Balancete$ANO),                                                  
FUN = sum)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.