vartors
# Read the doc and launch example
?vartors
example(vartors)
To be useful, vartors
need a simple database. Simple databases are defined as a single table database, with one variable by column, one observation by line and the name of the variable in the first line (header).
Example of simple database :
| ID|Birthdate |Gender |Study lvl | Heigh (m)| Weight (kg)| Siblings| Q1| Q2| |--:|:----------|:------|:---------|---------:|-----------:|--------:|--:|--:| | 1|2000-01-01 |male |primary | NA| 62.6| 3| 2| 1| | 2|2000-02-14 |male |primary | 1.68| 61.6| 1| 0| NA| | 3|2002-04-02 |male |primary | 1.76| 67.3| 1| 3| 1| | 4|2000-11-18 |female |primary | 1.67| 85.1| NA| 2| 2| | 5|2001-01-28 |male |primary | NA| 78.8| 3| 2| 3| | 6|2000-11-05 |male |primary | 1.69| 83.7| 6| 0| 2| | 7|2002-04-06 |male |primary | 1.74| 77.1| 4| 1| NA| | 8|2001-12-30 |male |secondary | 1.78| NA| NA| 1| 2| | 9|2000-11-13 |female |primary | 1.78| 62.3| 5| 0| NA| | 10|2001-08-22 |female |primary | 1.72| 97.6| 0| 1| 1|
Import this database in R. For example, if this database is in a .csv
fil ,type
raw_database <- read.csv("my_database.csv")
To create a skeleton of a variables description table, use descvars_skeleton
desc_skeleton <- descvars_skeleton(simpledb)
You will obtain a data.frame like this one (presented in two tables) :
|column |originalname |varlabel |description |comment |unit |type |rname | |:------|:------------|:-----------|:-----------|:-------|:----|:-------|:-----------| |A |ID |ID |NA |NA |NA |integer |ID | |B |Birthdate |Birthdate |NA |NA |NA |Date |Birthdate | |C |Gender |Gender |NA |NA |NA |factor |Gender | |D |Study lvl |Study lvl |NA |NA |NA |factor |Study.lvl | |E |Heigh (m) |Heigh (m) |NA |NA |NA |numeric |Heigh..m. | |F |Weight (kg) |Weight (kg) |NA |NA |NA |numeric |Weight..kg. | |G |Siblings |Siblings |NA |NA |NA |integer |Siblings | |H |Q1 |Q1 |NA |NA |NA |factor |Q1 | |I |Q2 |Q2 |NA |NA |NA |factor |Q2 |
|originalname |flevel1 |flabel1 |flevel2 |flabel2 |flevel3 |flabel3 |flevel4 |flabel4 | |:------------|:-------|:-------|:---------|:---------|:--------|:--------|:-------|:-------| |ID |NA |NA |NA |NA |NA |NA |NA |NA | |Birthdate |NA |NA |NA |NA |NA |NA |NA |NA | |Gender |male |male |female |female |NA |NA |NA |NA | |Study lvl |primary |primary |secondary |secondary |superior |superior |NA |NA | |Heigh (m) |NA |NA |NA |NA |NA |NA |NA |NA | |Weight (kg) |NA |NA |NA |NA |NA |NA |NA |NA | |Siblings |NA |NA |NA |NA |NA |NA |NA |NA | |Q1 |0 |0 |1 |1 |2 |2 |3 |3 | |Q2 |1 |1 |2 |2 |3 |3 |NA |NA |
Now, you have to ask the people who give you the database to explain each variable and fill this description of variable table. Just edit this, by using for example edit
or by saving the data.frame in .csv
use a spredsheet software like LibreOffice.
desc_complete <- edit(desc_skeleton)
Then you obtain an explicit description of the variables like this
|originalname |varlabel |description |comment |unit |type |rname | |:------------|:-----------------------|:-----------|:-------|:----|:---------|:-----------| |ID |ID |NA |NA |NA |character |id | |Birthdate |Birthdate |NA |NA |NA |Date |birth | |Gender |Gender |NA |NA |NA |factor |sex | |Study lvl |Study lvl |NA |NA |NA |ordered |study | |Heigh (m) |Heigh (m) |NA |NA |NA |numeric |heigh | |Weight (kg) |Weight (kg) |NA |NA |NA |numeric |weight | |Siblings |Siblings |NA |NA |NA |integer |siblings | |Q1 |Q1 - Like potatoes |NA |NA |NA |ordered |q1_potatoes | |Q2 |Q2 - Like french cheese |NA |NA |NA |ordered |q2_cheese |
|originalname |flevel1 |flabel1 |flevel2 |flabel2 |flevel3 |flabel3 |flevel4 |flabel4 | |:------------|:-------|:----------|:---------|:---------|:--------|:------------|:-------|:-------| |ID |NA |NA |NA |NA |NA |NA |NA |NA | |Birthdate |NA |NA |NA |NA |NA |NA |NA |NA | |Gender |male |male |female |female |NA |NA |NA |NA | |Study lvl |primary |primary |secondary |secondary |superior |superior |NA |NA | |Heigh (m) |NA |NA |NA |NA |NA |NA |NA |NA | |Weight (kg) |NA |NA |NA |NA |NA |NA |NA |NA | |Siblings |NA |NA |NA |NA |NA |NA |NA |NA | |Q1 |0 |Don't like |1 |Maybe |2 |A little bit |3 |A lot | |Q2 |1 |Don't like |1 |Maybe |2 |A little bit |3 |A lot |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.