0

How can I count the number of records per columns. The result would be like Realizados = 25,Atenção = 3,Regra = 11

structure(list(Realizados = structure(1:25, .Label = c("Alterar Orçamento", 
"Alterar Orçamento Cliente", "Alterar Sinistro", "Alterar Solicitação Manutenção", 
"Alterar Solicitação Veículo", "CheckList", "Cliente", "Contrato Locação", 
"COR", "Fornecedor", "Grupo Cliente", "Incluir Orçamento", "Incluir Sinistro", 
"Incluir Solicitação Manutenção", "Incluir Solicitação Veículo", 
"Modelo", "Multa", "Municipio", "Opcional", "Orçamento", "Serviço Peça", 
"Sinistro", "Solicitação Manutenção", "Solicitação Veículo", 
"Veículos"), class = "factor"), Atenção = structure(c(2L, 3L, 
4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("", "Categoria", "Faturamento", 
"Nota Fiscal"), class = "factor"), Regra = structure(c(2L, 3L, 
6L, 4L, 5L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("", "Alterar Devolução Veículo", 
"Classificação", "Devolução Veículo", "Editar Veículo Pool", 
"Filial", "Incluir Devolução Veículo", "Infração", "Preventiva Realizada", 
"Preventiva Realizar", "Tipo NF", "Veículo Pool"), class = "factor")), .Names = c("Realizados", 
"Atenção", "Regra"), class = "data.frame", row.names = c(NA, 
-25L))
Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
  • Please don't post pictures of data - they are difficult to work with/import. Instead post `dput()` of your data (or of a subset) so that we can see the classes of what is there. [See here for a tutorial on sharing data effectively](https://stackoverflow.com/q/5963269/903061). For your question, what is your data structure? Data frame? List? If it's a data frame, are those blank rows missing values, empty strings, white space, something else? The best way to answer all those questions at once is to post `dput(your_data)`. – Gregor Thomas Oct 10 '17 at 16:02
  • Also, please show any code you tried and didn't work. Where are you stuck? – Gregor Thomas Oct 10 '17 at 16:02
  • Thank you for the advices Gregor. I edited my post with dput. Is correct ? – Felipe Barbalho Costa Oct 10 '17 at 16:13
  • I tried to use aggregate functions,dplyr package but i don't understand . – Felipe Barbalho Costa Oct 10 '17 at 16:14

1 Answers1

0

This will count the number of rows in each column that are not equal to the empty string, ''. Calling your data df,

sapply(df, function(x) sum(x != ''))
# Realizados    Atenção      Regra 
#        25          3         11 
Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294