This function describes the variables of a vector or a dataset that might include labels imported with haven packages.
describe(x, ...)
# S3 method for factor
describe(x, n = 10, show.length = TRUE, freq.n.max = 10, ...)
# S3 method for numeric
describe(x, n = 10, show.length = TRUE, freq.n.max = 10, ...)
# S3 method for character
describe(x, n = 10, show.length = TRUE, freq.n.max = 10, ...)
# S3 method for default
describe(x, n = 10, show.length = TRUE, freq.n.max = 10, ...)
# S3 method for haven_labelled
describe(x, n = 10, show.length = TRUE, freq.n.max = 10, ...)
# S3 method for data.frame
describe(x, ..., n = 10, freq.n.max = 0)
# S3 method for description
print(x, ...)
object to describe
further arguments passed to or from other methods, see details
number of first values to display
display length of the vector?
display a frequency table if the number of unique values is less than this value, 0 to hide
an object of class description
.
When describing a data.frame, you can provide variable names as character strings. Using the "*" or "|" wildcards in a variable name will search for it using a regex match. The search will also take into account variable labels, if any. See examples.
data(hdv2003)
describe(hdv2003$sexe)
#> [2000 obs.]
#> nominal factor: "Femme" "Femme" "Homme" "Homme" "Femme" "Femme" "Femme" "Homme" "Femme" "Homme" ...
#> 2 levels: Homme | Femme
#> NAs: 0 (0%)
#>
#> n %
#> Homme 899 45
#> Femme 1101 55
#> Total 2000 100
describe(hdv2003$age)
#> [2000 obs.]
#> integer: 28 23 59 34 71 35 60 47 20 28 ...
#> min: 18 - max: 97 - NAs: 0 (0%) - 78 unique values
describe(hdv2003)
#> [2000 obs. x 20 variables] tbl_df tbl data.frame
#>
#> $id:
#> integer: 1 2 3 4 5 6 7 8 9 10 ...
#> min: 1 - max: 2000 - NAs: 0 (0%) - 2000 unique values
#>
#> $age:
#> integer: 28 23 59 34 71 35 60 47 20 28 ...
#> min: 18 - max: 97 - NAs: 0 (0%) - 78 unique values
#>
#> $sexe:
#> nominal factor: "Femme" "Femme" "Homme" "Homme" "Femme" "Femme" "Femme" "Homme" "Femme" "Homme" ...
#> 2 levels: Homme | Femme
#> NAs: 0 (0%)
#>
#> $nivetud:
#> nominal factor: "Enseignement superieur y compris technique superieur" NA "Derniere annee d'etudes primaires" "Enseignement superieur y compris technique superieur" "Derniere annee d'etudes primaires" "Enseignement technique ou professionnel court" "Derniere annee d'etudes primaires" "Enseignement technique ou professionnel court" NA "Enseignement technique ou professionnel long" ...
#> 8 levels: N'a jamais fait d'etudes | A arrete ses etudes, avant la derniere annee d'etudes primaires | Derniere annee d'etudes primaires | 1er cycle | 2eme cycle | Enseignement technique ou professionnel court | Enseignement technique ou professionnel long | Enseignement superieur y compris technique superieur
#> NAs: 112 (5.6%)
#>
#> $poids:
#> numeric: 2634.3982157 9738.3957759 3994.1024587 5731.6615081 4329.0940022 8674.6993828 6165.8034861 12891.640759 7808.8720636 2277.160471 ...
#> min: 78.0783403 - max: 31092.14132 - NAs: 0 (0%) - 1877 unique values
#>
#> $occup:
#> nominal factor: "Exerce une profession" "Etudiant, eleve" "Exerce une profession" "Exerce une profession" "Retraite" "Exerce une profession" "Au foyer" "Exerce une profession" "Etudiant, eleve" "Exerce une profession" ...
#> 7 levels: Exerce une profession | Chomeur | Etudiant, eleve | Retraite | Retire des affaires | Au foyer | Autre inactif
#> NAs: 0 (0%)
#>
#> $qualif:
#> nominal factor: "Employe" NA "Technicien" "Technicien" "Employe" "Employe" "Ouvrier qualifie" "Ouvrier qualifie" NA "Autre" ...
#> 7 levels: Ouvrier specialise | Ouvrier qualifie | Technicien | Profession intermediaire | Cadre | Employe | Autre
#> NAs: 347 (17.3%)
#>
#> $freres.soeurs:
#> integer: 8 2 2 1 0 5 1 5 4 2 ...
#> min: 0 - max: 22 - NAs: 0 (0%) - 19 unique values
#>
#> $clso:
#> nominal factor: "Oui" "Oui" "Non" "Non" "Oui" "Non" "Oui" "Non" "Oui" "Non" ...
#> 3 levels: Oui | Non | Ne sait pas
#> NAs: 0 (0%)
#>
#> $relig:
#> nominal factor: "Ni croyance ni appartenance" "Ni croyance ni appartenance" "Ni croyance ni appartenance" "Appartenance sans pratique" "Pratiquant regulier" "Ni croyance ni appartenance" "Appartenance sans pratique" "Ni croyance ni appartenance" "Appartenance sans pratique" "Pratiquant occasionnel" ...
#> 6 levels: Pratiquant regulier | Pratiquant occasionnel | Appartenance sans pratique | Ni croyance ni appartenance | Rejet | NSP ou NVPR
#> NAs: 0 (0%)
#>
#> $trav.imp:
#> nominal factor: "Peu important" NA "Aussi important que le reste" "Moins important que le reste" NA "Le plus important" NA "Peu important" NA "Moins important que le reste" ...
#> 4 levels: Le plus important | Aussi important que le reste | Moins important que le reste | Peu important
#> NAs: 952 (47.6%)
#>
#> $trav.satisf:
#> nominal factor: "Insatisfaction" NA "Equilibre" "Satisfaction" NA "Equilibre" NA "Insatisfaction" NA "Satisfaction" ...
#> 3 levels: Satisfaction | Insatisfaction | Equilibre
#> NAs: 952 (47.6%)
#>
#> $hard.rock:
#> nominal factor: "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" ...
#> 2 levels: Non | Oui
#> NAs: 0 (0%)
#>
#> $lecture.bd:
#> nominal factor: "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" ...
#> 2 levels: Non | Oui
#> NAs: 0 (0%)
#>
#> $peche.chasse:
#> nominal factor: "Non" "Non" "Non" "Non" "Non" "Non" "Oui" "Oui" "Non" "Non" ...
#> 2 levels: Non | Oui
#> NAs: 0 (0%)
#>
#> $cuisine:
#> nominal factor: "Oui" "Non" "Non" "Oui" "Non" "Non" "Oui" "Oui" "Non" "Non" ...
#> 2 levels: Non | Oui
#> NAs: 0 (0%)
#>
#> $bricol:
#> nominal factor: "Non" "Non" "Non" "Oui" "Non" "Non" "Non" "Oui" "Non" "Non" ...
#> 2 levels: Non | Oui
#> NAs: 0 (0%)
#>
#> $cinema:
#> nominal factor: "Non" "Oui" "Non" "Oui" "Non" "Oui" "Non" "Non" "Oui" "Oui" ...
#> 2 levels: Non | Oui
#> NAs: 0 (0%)
#>
#> $sport:
#> nominal factor: "Non" "Oui" "Oui" "Oui" "Non" "Oui" "Non" "Non" "Non" "Oui" ...
#> 2 levels: Non | Oui
#> NAs: 0 (0%)
#>
#> $heures.tv:
#> numeric: 0 1 0 2 3 2 2.9 1 2 2 ...
#> min: 0 - max: 12 - NAs: 5 (0.2%) - 30 unique values
describe(hdv2003, "cuisine", "heures.tv")
#> [2000 obs. x 20 variables] tbl_df tbl data.frame
#>
#> $cuisine:
#> nominal factor: "Oui" "Non" "Non" "Oui" "Non" "Non" "Oui" "Oui" "Non" "Non" ...
#> 2 levels: Non | Oui
#> NAs: 0 (0%)
#>
#> $heures.tv:
#> numeric: 0 1 0 2 3 2 2.9 1 2 2 ...
#> min: 0 - max: 12 - NAs: 5 (0.2%) - 30 unique values
describe(hdv2003, "trav*")
#> [2000 obs. x 20 variables] tbl_df tbl data.frame
#>
#> $occup:
#> nominal factor: "Exerce une profession" "Etudiant, eleve" "Exerce une profession" "Exerce une profession" "Retraite" "Exerce une profession" "Au foyer" "Exerce une profession" "Etudiant, eleve" "Exerce une profession" ...
#> 7 levels: Exerce une profession | Chomeur | Etudiant, eleve | Retraite | Retire des affaires | Au foyer | Autre inactif
#> NAs: 0 (0%)
#>
#> $trav.imp:
#> nominal factor: "Peu important" NA "Aussi important que le reste" "Moins important que le reste" NA "Le plus important" NA "Peu important" NA "Moins important que le reste" ...
#> 4 levels: Le plus important | Aussi important que le reste | Moins important que le reste | Peu important
#> NAs: 952 (47.6%)
#>
#> $trav.satisf:
#> nominal factor: "Insatisfaction" NA "Equilibre" "Satisfaction" NA "Equilibre" NA "Insatisfaction" NA "Satisfaction" ...
#> 3 levels: Satisfaction | Insatisfaction | Equilibre
#> NAs: 952 (47.6%)
describe(hdv2003, "trav|lecture")
#> [2000 obs. x 20 variables] tbl_df tbl data.frame
#>
#> $trav.imp:
#> nominal factor: "Peu important" NA "Aussi important que le reste" "Moins important que le reste" NA "Le plus important" NA "Peu important" NA "Moins important que le reste" ...
#> 4 levels: Le plus important | Aussi important que le reste | Moins important que le reste | Peu important
#> NAs: 952 (47.6%)
#>
#> $trav.satisf:
#> nominal factor: "Insatisfaction" NA "Equilibre" "Satisfaction" NA "Equilibre" NA "Insatisfaction" NA "Satisfaction" ...
#> 3 levels: Satisfaction | Insatisfaction | Equilibre
#> NAs: 952 (47.6%)
#>
#> $lecture.bd:
#> nominal factor: "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" ...
#> 2 levels: Non | Oui
#> NAs: 0 (0%)
describe(hdv2003, "trav", "lecture")
#> [2000 obs. x 20 variables] tbl_df tbl data.frame
#>
#> $trav.imp:
#> nominal factor: "Peu important" NA "Aussi important que le reste" "Moins important que le reste" NA "Le plus important" NA "Peu important" NA "Moins important que le reste" ...
#> 4 levels: Le plus important | Aussi important que le reste | Moins important que le reste | Peu important
#> NAs: 952 (47.6%)
#>
#> $trav.satisf:
#> nominal factor: "Insatisfaction" NA "Equilibre" "Satisfaction" NA "Equilibre" NA "Insatisfaction" NA "Satisfaction" ...
#> 3 levels: Satisfaction | Insatisfaction | Equilibre
#> NAs: 952 (47.6%)
#>
#> $lecture.bd:
#> nominal factor: "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" "Non" ...
#> 2 levels: Non | Oui
#> NAs: 0 (0%)
data(fertility)
describe(women$residency)
#> [2000 obs.] Urban / rural residency
#> labelled double: 2 2 2 2 2 2 2 2 2 2 ...
#> min: 1 - max: 2 - NAs: 0 (0%) - 2 unique values
#> 2 value labels: [1] urban [2] rural
#>
#> n %
#> [1] urban 912 45.6
#> [2] rural 1088 54.4
#> Total 2000 100.0
describe(women)
#> [2000 obs. x 17 variables] tbl_df tbl data.frame
#>
#> $id_woman: Woman Id
#> numeric: 391 1643 85 881 1981 1072 1978 1607 738 1656 ...
#> min: 1 - max: 2000 - NAs: 0 (0%) - 2000 unique values
#>
#> $id_household: Household Id
#> numeric: 381 1515 85 844 1797 1015 1794 1486 711 1525 ...
#> min: 1 - max: 1814 - NAs: 0 (0%) - 1814 unique values
#>
#> $weight: Sample weight
#> numeric: 1.80315 1.80315 1.80315 1.80315 1.80315 0.997934 0.997934 0.997934 0.192455 0.192455 ...
#> min: 0.044629 - max: 4.396831 - NAs: 0 (0%) - 351 unique values
#>
#> $interview_date: Interview date
#> Date: 2012-05-05 2012-01-23 2012-01-21 2012-01-06 2012-05-11 2012-02-20 2012-02-23 2012-02-20 2012-03-09 2012-03-15 ...
#> min: 2011-12-01 - max: 2012-05-31 - NAs: 0 (0%) - 165 unique values
#>
#> $date_of_birth: Date of birth
#> Date: 1997-03-07 1982-01-06 1979-01-01 1968-03-29 1986-05-25 1993-07-03 1967-01-28 1989-01-21 1962-07-24 1980-12-25 ...
#> min: 1962-02-07 - max: 1997-03-13 - NAs: 0 (0%) - 1740 unique values
#>
#> $age: Age at last anniversary (in years)
#> numeric: 15 30 33 43 25 18 45 23 49 31 ...
#> min: 14 - max: 49 - NAs: 0 (0%) - 36 unique values
#>
#> $residency: Urban / rural residency
#> labelled double: 2 2 2 2 2 2 2 2 2 2 ...
#> min: 1 - max: 2 - NAs: 0 (0%) - 2 unique values
#> 2 value labels: [1] urban [2] rural
#>
#> $region: Region
#> labelled double: 4 4 4 4 4 3 3 3 3 3 ...
#> min: 1 - max: 4 - NAs: 0 (0%) - 4 unique values
#> 4 value labels: [1] North [2] East [3] South [4] West
#>
#> $instruction: Level of instruction
#> labelled double: 0 0 0 0 1 0 0 0 0 0 ...
#> min: 0 - max: 3 - NAs: 0 (0%) - 4 unique values
#> 4 value labels: [0] none [1] primary [2] secondary [3] higher
#>
#> $employed: Employed?
#> labelled_spss double: 1 1 0 1 1 0 1 0 1 1 ...
#> min: 0 - max: 9 - NAs: 7 (0.4%) - 3 unique values
#> 3 value labels: [0] no [1] yes [9] missing
#> user-defined na values: 9
#>
#> $matri: Matrimonial status
#> labelled double: 0 2 2 2 1 0 1 1 2 5 ...
#> min: 0 - max: 5 - NAs: 0 (0%) - 6 unique values
#> 6 value labels: [0] single [1] married [2] living together [3] windowed [4] divorced [5] separated
#>
#> $religion: Religion
#> labelled double: 1 3 2 3 2 2 3 1 3 3 ...
#> min: 1 - max: 5 - NAs: 4 (0.2%) - 6 unique values
#> 5 value labels: [1] Muslim [2] Christian [3] Protestant [4] no religion [5] other
#>
#> $newspaper: Read newspaper?
#> labelled double: 0 0 0 0 0 0 0 0 0 0 ...
#> min: 0 - max: 1 - NAs: 0 (0%) - 2 unique values
#> 2 value labels: [0] no [1] yes
#>
#> $radio: Listen to radio?
#> labelled double: 0 1 1 0 0 1 1 0 0 0 ...
#> min: 0 - max: 1 - NAs: 0 (0%) - 2 unique values
#> 2 value labels: [0] no [1] yes
#>
#> $tv: Watch TV?
#> labelled double: 0 0 0 0 0 1 0 0 0 0 ...
#> min: 0 - max: 1 - NAs: 0 (0%) - 2 unique values
#> 2 value labels: [0] no [1] yes
#>
#> $ideal_nb_children: Ideal number of children
#> labelled_spss double: 4 4 4 4 4 5 10 5 4 5 ...
#> min: 0 - max: 99 - NAs: 0 (0%) - 18 unique values
#> 2 value labels: [96] don't know [99] missing
#>
#> $test: Ever tested for HIV?
#> labelled_spss double: 0 9 0 0 1 0 0 0 0 1 ...
#> min: 0 - max: 9 - NAs: 29 (1.5%) - 3 unique values
#> 3 value labels: [0] no [1] yes [9] missing
#> user-defined na values: 9
describe(women, "id")
#> [2000 obs. x 17 variables] tbl_df tbl data.frame
#>
#> $id_woman: Woman Id
#> numeric: 391 1643 85 881 1981 1072 1978 1607 738 1656 ...
#> min: 1 - max: 2000 - NAs: 0 (0%) - 2000 unique values
#>
#> $id_household: Household Id
#> numeric: 381 1515 85 844 1797 1015 1794 1486 711 1525 ...
#> min: 1 - max: 1814 - NAs: 0 (0%) - 1814 unique values
#>
#> $residency: Urban / rural residency
#> labelled double: 2 2 2 2 2 2 2 2 2 2 ...
#> min: 1 - max: 2 - NAs: 0 (0%) - 2 unique values
#> 2 value labels: [1] urban [2] rural
#>
#> $ideal_nb_children: Ideal number of children
#> labelled_spss double: 4 4 4 4 4 5 10 5 4 5 ...
#> min: 0 - max: 99 - NAs: 0 (0%) - 18 unique values
#> 2 value labels: [96] don't know [99] missing