@@ -10,93 +10,93 @@ om <- calcOutlierMap(data)
10
10
11
11
12
12
# Testing ------
13
- test_that(" `getFlaggedIds ()` returns error if `x` is not the required class" , {
13
+ test_that(" `getOutlierIds ()` returns error if `x` is not the required class" , {
14
14
expect_error(
15
- getFlaggedIds (1 : 3 ),
15
+ getOutlierIds (1 : 3 ),
16
16
" Input `x` object must be class `outlier_map`!"
17
17
)
18
18
expect_error(
19
- getFlaggedIds (" foo" ),
19
+ getOutlierIds (" foo" ),
20
20
" Input `x` object must be class `outlier_map`!"
21
21
)
22
22
expect_error(
23
- getFlaggedIds (data.frame (x = 1 )),
23
+ getOutlierIds (data.frame (x = 1 )),
24
24
" Input `x` object must be class `outlier_map`!"
25
25
)
26
26
})
27
27
28
- test_that(" `getFlaggedIds ()` returns error if `data` is not a df" , {
28
+ test_that(" `getOutlierIds ()` returns error if `data` is not a df" , {
29
29
expect_error(
30
- getFlaggedIds (om , data = 1 : 3 ),
30
+ getOutlierIds (om , data = 1 : 3 ),
31
31
" The `data` argument must be a `data.frame` object."
32
32
)
33
33
})
34
34
35
- test_that(" `getFlaggedIds ()` returns error if flags arg is not in [0, 1]" , {
35
+ test_that(" `getOutlierIds ()` returns error if flags arg is not in [0, 1]" , {
36
36
expect_error(
37
- getFlaggedIds (om , flags = 1.1 ),
37
+ getOutlierIds (om , flags = 1.1 ),
38
38
" `flags =` argument must be between 0 and 1!"
39
39
)
40
40
expect_error(
41
- getFlaggedIds (om , flags = - 0.1 ),
41
+ getOutlierIds (om , flags = - 0.1 ),
42
42
" `flags =` argument must be between 0 and 1!"
43
43
)
44
44
})
45
45
46
- test_that(" `getFlaggedIds ()` trips error if `include` not in `data`" , {
46
+ test_that(" `getOutlierIds ()` trips error if `include` not in `data`" , {
47
47
expect_error(
48
- getFlaggedIds (om , 0.05 , data , " foo" ),
48
+ getOutlierIds (om , 0.05 , data , " foo" ),
49
49
" All `include` must be in `data`."
50
50
)
51
51
})
52
52
53
- test_that(" `getFlaggedIds ()` returns 0 row df and msg if no obs are flagged" , {
54
- expect_message(outliers <- getFlaggedIds (om , 0.8 ),
53
+ test_that(" `getOutlierIds ()` returns 0 row df and msg if no obs are flagged" , {
54
+ expect_message(outliers <- getOutlierIds (om , 0.8 ),
55
55
" No observations were flagged at this flagging proportion:" )
56
56
57
57
expect_s3_class(outliers , " data.frame" )
58
58
expect_false(has_rn(outliers ))
59
59
expect_equal(outliers , data.frame (idx = numeric (0 )))
60
60
})
61
61
62
- test_that(" `getFlaggedIds ()` works on `calcOutlierMap` object, using default
62
+ test_that(" `getOutlierIds ()` works on `calcOutlierMap` object, using default
63
63
flags = 0.05, no included variables" , {
64
- outliers <- getFlaggedIds (om , data = data )
64
+ outliers <- getOutlierIds (om , data = data )
65
65
expect_s3_class(outliers , " data.frame" )
66
66
expect_false(has_rn(outliers ))
67
67
expect_equal(outliers , data.frame (idx = c(12 , 18 )))
68
68
})
69
69
70
- test_that(" `getFlaggedIds ()` works on `calcOutlierMap` object, using
70
+ test_that(" `getOutlierIds ()` works on `calcOutlierMap` object, using
71
71
flags = 0.02, one included variable" , {
72
- outliers <- getFlaggedIds (om , 0.02 , data , " SampleId" )
72
+ outliers <- getOutlierIds (om , 0.02 , data , " SampleId" )
73
73
expect_s3_class(outliers , " data.frame" )
74
74
expect_false(has_rn(outliers ))
75
75
expect_equal(outliers , data.frame (idx = c(12 , 13 , 18 , 20 ),
76
76
SampleId = c(" 14" , " 15" , " 21" , " 23" )))
77
77
})
78
78
79
- test_that(" `getFlaggedIds ()` works on `calcOutlierMap` object, using
79
+ test_that(" `getOutlierIds ()` works on `calcOutlierMap` object, using
80
80
flags = 0.1, multiple included variables" , {
81
- outliers <- getFlaggedIds (om , 0.1 , data , c(" SampleId" , " Sex" ))
81
+ outliers <- getOutlierIds (om , 0.1 , data , c(" SampleId" , " Sex" ))
82
82
expect_s3_class(outliers , " data.frame" )
83
83
expect_false(has_rn(outliers ))
84
84
expect_equal(outliers , data.frame (idx = 12 ,
85
85
SampleId = " 14" ,
86
86
Sex = " M" ))
87
87
})
88
88
89
- test_that(" `getFlaggedIds ()` works on `calcOutlierMap` object with `data = NULL`" , {
89
+ test_that(" `getOutlierIds ()` works on `calcOutlierMap` object with `data = NULL`" , {
90
90
# data = NULL, include = NULL
91
- outliers <- getFlaggedIds (om )
91
+ outliers <- getOutlierIds (om )
92
92
expect_s3_class(outliers , " data.frame" )
93
93
expect_false(has_rn(outliers ))
94
94
expect_equal(outliers , data.frame (idx = c(12 , 18 )))
95
95
})
96
96
97
- test_that(" `getFlaggedIds ()` `include` is ignored `data = NULL`" , {
97
+ test_that(" `getOutlierIds ()` `include` is ignored `data = NULL`" , {
98
98
expect_equal(
99
- getFlaggedIds (om ),
100
- getFlaggedIds (om , data = NULL , include = " SampleId" ) # test if `data = NULL`
99
+ getOutlierIds (om ),
100
+ getOutlierIds (om , data = NULL , include = " SampleId" ) # test if `data = NULL`
101
101
)
102
102
})
0 commit comments