Project: Time Use Visualizations
Step 1. Download ATUS-X extractCreate your ATUS-X extract from IPUMS website. Make sure to include 'DURATION', 'CASEID', 'ACTIVITY', 'ACTLINE' and weights variables ('WT06') if needed. Save .dta 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 fileCreate 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.
Step 3. Transform your data
Using the 'timeuse' package (Link), contains five functions that will help you with that:
Step 4. Create the visualizationsUsing one of the following packages:
Step 5. Save your visualization as .html fileIn 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 websiteIf 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 blogFor example, in WordPress you can do the following to add your graph to your blog:
ExamplesThese 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")