Basic Descriptive Functions

Asked

Viewed 69 times

2

I’m analyzing a monitoring database of Conservation Units.

I’m struggling with some basic functions.

I would like to know what functions I should use to achieve the following values with the R:

  1. Number of interviews (id.entrevista) per resident (id.household)
  2. Average number of interviews per resident
  3. Average number of interviews per resex

More than one line can refer to the same id.entrevista, for example, the id.entrevista 43 has two lines with 43. This number is not value, and yes, the identification of the interview in the database.

I tried with the function aggregate, but not succeed, since my factor variables are "character".

Below is an example of my database containing 1476 lines

inserir a descrição da imagem aqui

Could you help me, please, get the job I need?

Follow data in format dput:

set.seed(123)
dados <- data.frame(
  id.entrevista = 1:14, 
  id.household = sample(c("Luiz", "José", "Gelson", "Renan"), 14, TRUE),
  resex = "iriri"
)
  • 1

    Welcome to Stackoverflow! Unfortunately, this question cannot be reproduced by anyone trying to answer it. Please, take a look at this link and see how to ask a reproducible question in R. So, people who wish to help you will be able to do this in the best possible way.

  • Can you please, edit the question with the departure of dput(dados) or, if the base is too large, dput(head(dados, 20))? Note: dados is the base name, for example a data frame..

  • 1

    Until you reopen the question I’ll leave it here commented. Using dplyr the solutions go through use count() and then average

No answers

Browser other questions tagged

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