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
:
- Number of interviews (
id.entrevista
) per resident (id.household
) - Average number of interviews per resident
- 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
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"
)
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.
– Marcus Nunes
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..– Rui Barradas
Until you reopen the question I’ll leave it here commented. Using dplyr the solutions go through use
count()
and then average– Tomás Barcellos