Skip to content

Kolpashnikova/package_R_tempogram

Repository files navigation

package_R_tempogram

Interactive Tempogram in R

Installation

devtools::install_github("Kolpashnikova/package_R_tempogram")

library(tempogram)

Description

Generates a tempogram in NVD3 JavaScript. It takes in a json file with keys and values.

Each 'key' variable represents an activity, such as "Sleep", "Housework", "Paid Work", etc.

Each 'values' variable contains tuples of timestamps and number of observations corresponding to the timestamp. Timestamps can start at 240 representing number of minutes from midnight to 4am. and end at 1679 representing number of minutes from midnight of the previous day to 3:59am of the next.

How it looks like

You can try the interactive demo here: (https://kolpashnikova.github.io/tempogram)

Tempogram One activity

An example of a json file:

The json data that you need to enter into function should look like this ('key' and 'values' are necessary variables.)

["key":"Sleep","values":[[240,7785.6229],[307,6196.2182],[374,4110.7414], [441,2390.5974],[508,1117.2862],[575,699.7444],[642,497.4546],[709,461.145], [776,468.1627],[843,452.7021],[910,432.8564],[977,352.4974],[1044,305.316], [1111,504.4961],[1178,1110.2094],[1245,3008.7462],[1312,5685.1459],[1379,7872.8489], [1446,8446.7475],[1513,8691.5399],[1580,8704.8851],[1679,8675.8885]],"_row":"a", "key":"Personal Care","values":[[240,331.926],[307,662.4909],[374,729.8447], [441,532.9152],[508,374.9529],[575,294.1402],[642,197.4594],[709,159.6148], [776,160.4106],[843,180.356],[910,184.5209],[977,217.9758],[1044,233.5801], [1111,280.4983],[1178,451.196],[1245,366.9532],[1312,202.6713],[1379,115.2747], [1446,33.9265],[1513,24.1379],[1580,43.3983],[1679,55.3272]],"_row":"b", "key":"Housework","values":[[240,142.1455],[307,364.8986],[374,707.6559], [441,1023.0097],[508,1227.4956],[575,1287.5524],[642,1347.1956],[709,1208.5041], [776,1184.4672],[843,1238.5155],[910,1337.5624],[977,1558.0702],[1044,1296.5265], [1111,873.1308],[1178,559.5919],[1245,306.044],[1312,143.9368],[1379,48.7172], [1446,31.8538],[1513,16.4301],[1580,21.5055],[1679,9.9848]],"_row":"c", "key":"Childcare","values":[[240,21.7767],[307,121.1892],[374,220.9026], [441,222.2808],[508,227.5564],[575,216.3986],[642,194.0618],[709,219.3154], [776,217.2562],[843,251.6816],[910,268.4751],[977,271.728],[1044,315.7279], [1111,396.4089],[1178,265.5326],[1245,114.4931],[1312,33.5035],[1379,10.6389], [1446,10.3835],[1513,6.0778],[1580,10.3605],[1679,9.3027]],"_row":"d", "key":"Adult care","values":[[240,11.8934],[307,15.3094],[374,41.2731], [441,47.2098],[508,65.4641],[575,93.8446],[642,77.5144],[709,87.831], [776,73.9226],[843,65.9123],[910,57.1159],[977,60.8699],[1044,42.4575], [1111,41.5023],[1178,26.9416],[1245,15.1304],[1312,10.5158],[1379,7.1762], [1446,1.1265],[1513,1.805],[1580,4.9296],[1679,1.7921]],"_row":"e", "key":"Working and Education","values":[[240,260.3456],[307,615.5785], [374,1391.9049],[441,2571.5213],[508,3121.8037],[575,3300.6243], [642,3122.2857],[709,2790.2985],[776,3058.7718],[843,2745.5795],[910,2332.4573], [977,1407.0727],[1044,822.3769],[1111,686.1307],[1178,591.712],[1245,513.9097], [1312,331.0949],[1379,150.7481],[1446,110.8769],[1513,98.3579],[1580,104.6614], [1679,105.9518]],"_row":"f","key":"Shopping and Services","values":[[240,5.9414], [307,15.2268],[374,46.3733],[441,112.3811],[508,255.7601],[575,379.5057], [642,396.6291],[709,388.3378],[776,371.1719],[843,339.3387],[910,302.8779], [977,296.5767],[1044,231.2336],[1111,112.332],[1178,79.5336],[1245,23.536], [1312,8.2471],[1379,5.3062],[1446,4.1941],[1513,1.4803],[1580,1.4803], [1679,0.4294]],"_row":"g","key":"Eating","values":[[240,98.9277], [307,243.8624],[374,450.5148],[441,544.5041],[508,419.9653],[575,309.0399], [642,658.424],[709,1001.2518],[776,432.5263],[843,301.9091],[910,406.6496], [977,859.886],[1044,1380.5171],[1111,965.4475],[1178,455.6418],[1245,162.2005], [1312,66.6194],[1379,27.8322],[1446,20.8934],[1513,14.8973],[1580,13.349], [1679,24.7408]],"_row":"h","key":"Leisure","values":[[240,239.414], [307,464.3622],[374,732.6557],[441,1057.1534],[508,1558.9105],[575,1845.93], [642,1952.2374],[709,2106.5295],[776,2224.0323],[843,2516.2512],[910,2751.7516], [977,3074.1697],[1044,3697.5043],[1111,4689.9861],[1178,5209.251], [1245,4398.7818],[1312,2483.2779],[1379,754.3208],[1446,382.8486], [1513,204.8146],[1580,158.1335],[1679,164.6305]],"_row":"i", "key":"Sports","values":[[240,50.4979],[307,99.0457],[374,166.4674], [441,182.2592],[508,192.4697],[575,177.4903],[642,172.5253],[709,166.3535], [776,181.4774],[843,223.3143],[910,239.2746],[977,253.939],[1044,189.5317], [1111,138.0371],[1178,84.3056],[1245,49.9715],[1312,29.1828],[1379,9.7247], [1446,8.2673],[1513,3.5999],[1580,0.5414],[1679,2.7322]],"_row":"j", "key":"Travel","values":[[240,138.509],[307,288.8181],[374,488.6663], [441,403.168],[508,525.3356],[575,482.7296],[642,471.2128],[709,497.8186], [776,714.801],[843,771.4396],[910,773.4583],[977,734.2147],[1044,572.2285], [1111,399.0302],[1178,253.0847],[1245,127.2335],[1312,92.8047], [1379,84.412],[1446,35.8818],[1513,23.8594],[1580,23.7553],[1679,36.22]],"_row":"k"]

Usage

tempogram(df)

References

Kolpashnikova, Kamila. (2022). Interactive Tempogram in R. Toronto,ON: York University.