-
Notifications
You must be signed in to change notification settings - Fork 8
/
test-full-workflow.R
68 lines (50 loc) · 1.77 KB
/
test-full-workflow.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
###
### DataLoader R6
###
# Initialize new object
testObject <- DataLoader$new()
# Connect to API
testObject$connect(appname = "cdlr",
key = "227FWR",
secret = "3089e3d1ac5dde1aa00b54a0c8661f42"
)
testObject$connect(cache.file = "~/Downloads/.httr-oauth")
# Get Daily data for all possible activities
all.daily.activities <- getDailyResourcePathList()
testObject$request(
type = 'day',
activities = all.daily.activities,
start.date = "2016-01-20",
end.date = "2016-02-05",
path = "~/check-daily/")
# Get Intraday data for all possible activities
all.intraday.activities <- getIntradayResourcePathList()
testObject$request(
type = 'intraday',
activities = all.intraday.activities,
start.date = "2016-02-01",
path = "~/check-intraday/")
###
### FitAnalyzer R6
###
# Get JSON files and build dataframe
masterPath <- "~/check-daily/"
ana <- FitAnalyzer$new()
masterData <- ana$getAnalysisFrame(folder = masterPath , analysis.type = "daily")
# Plot a chart
ana$showCharts(data = masterData, activity = "steps", average = 7)
### Final tests
# Daily analysis
masterPath <- system.file("extdata", "daily-time-series", package = "fitcoach")
ana <- FitAnalyzer$new("calories")
ts <- ana$getAnalysisFrame(folder = masterPath, analysis.type = "daily")
vars <- ana$findImportantVariables(tsDataFrame = ts, seed = 12345)
vars <- ana$findImportantVariables()
ana$showMostImportantCharts(ts)
# Intra-day analysis
masterPath <- system.file("extdata", "intra-daily-timeseries", package = "fitcoach")
ana <- FitAnalyzer$new("calories")
intra <- ana$getAnalysisFrame(folder = masterPath, analysis.type = "intra.day")
vars <- ana$findImportantVariables(intra)
vars <- sort(vars, decreasing = TRUE)
ana$showMostImportantCharts(intra)