Step 1. Download ATUS-X extract
Create your ATUS-X extract from IPUMS website. Make sure to include ‘DURATION’, ‘CASEID’, ‘PERNUM’, ‘ACTIVITY’, ‘ACTLINE’ and weights variables (‘WT06’) if needed. Save .dat and .xml file, preferably in a new created ‘data’ folder.
Load extract into R using ‘ipumsr’ package.
Step 2. Download or create your own activity codes file
Create an activities code file, or you can download mine. It has to be a .csv file with 3 columns (ACTIVITY, Name, Alphabet).
- ACTIVITY is the activity code from ATUS-X, ranges from 10101 to 509999,
- Name is the name you want to give to this activity code, e.g. ‘Sleep,’ ‘Leisure,’ etc.,
- Alphabet is an alphabet letter (a to z) to code the activities.
Make sure that your number of recoded activities does not exceed the number of letters in the English alphabet (26), although potentially ASCII character set could be used.
NB: it is not recommended to have more than 12 activity re-codes because it will be difficult to find colour palettes.
Step 3. Transform your data
Using the ‘timeuse’ package (Link), contains five functions that will help you with that:
Each function correspond to the visualization that you want to create.
Step 4. Create the visualizations
Using one of the following packages:
create your visualization. Please read the instructions on corresponding GitHub.
Step 5. Save your visualization as .html file
In the viewer of your RStudio, choose ‘Save as Web Page…” and save your file as ‘myfile.html’.
Step 6. Upload your html file to your GitHub page or website
If you have a GitHub.io page, upload it to your main folder, and your file will be viewable at <yourGitName>.github.io/<yourfilename>
Step 7. Use <iframes> to add your visualization to your blog
For example, in WordPress you can do the following to add your graph to your blog:
These lines will create your tempogram from ‘data’ (data = ATUS-X extract).
tem <- tu_tempogram(data, w = "WT06") tempogram(toJSON(tem)) #don't forget to use toJSON from 'jsonlite' package)
If you need to change width or height of the visualization, use these:
tempogram(toJSON(tem), width="auto", height = "550px")