The R Project SVN R

Rev

Rev 63178 | Rev 63381 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 63178 Rev 63202
Line 1... Line 1...
1
 
1
 
2
R Under development (unstable) (2013-07-04 r63177) -- "Unsuffered Consequences"
2
R Under development (unstable) (2013-07-06 r63201) -- "Unsuffered Consequences"
3
Copyright (C) 2013 The R Foundation for Statistical Computing
3
Copyright (C) 2013 The R Foundation for Statistical Computing
4
Platform: x86_64-unknown-linux-gnu (64-bit)
4
Platform: x86_64-unknown-linux-gnu (64-bit)
5
 
5
 
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
7
You are welcome to redistribute it under certain conditions.
7
You are welcome to redistribute it under certain conditions.
Line 98... Line 98...
98
[1] "* "
98
[1] "* "
99
 
99
 
100
$enumFormat
100
$enumFormat
101
function (n) 
101
function (n) 
102
sprintf("%d. ", n)
102
sprintf("%d. ", n)
103
<environment: 0x2ecf050>
103
<environment: 0x1dcc408>
104
 
104
 
105
$showURLs
105
$showURLs
106
[1] FALSE
106
[1] FALSE
107
 
107
 
108
$code_quote
108
$code_quote
Line 132... Line 132...
132
[1] "* "
132
[1] "* "
133
 
133
 
134
$enumFormat
134
$enumFormat
135
function (n) 
135
function (n) 
136
sprintf("%d. ", n)
136
sprintf("%d. ", n)
137
<environment: 0x2ecf050>
137
<environment: 0x1dcc408>
138
 
138
 
139
$showURLs
139
$showURLs
140
[1] FALSE
140
[1] FALSE
141
 
141
 
142
$code_quote
142
$code_quote
Line 166... Line 166...
166
[1] "* "
166
[1] "* "
167
 
167
 
168
$enumFormat
168
$enumFormat
169
function (n) 
169
function (n) 
170
sprintf("%d. ", n)
170
sprintf("%d. ", n)
171
<environment: 0x2ecf050>
171
<environment: 0x1dcc408>
172
 
172
 
173
$showURLs
173
$showURLs
174
[1] FALSE
174
[1] FALSE
175
 
175
 
176
$code_quote
176
$code_quote
Line 202... Line 202...
202
> 
202
> 
203
> flush(stderr()); flush(stdout())
203
> flush(stderr()); flush(stdout())
204
> 
204
> 
205
> ### Name: assertCondition
205
> ### Name: assertCondition
206
> ### Title: Asserting Error Conditions
206
> ### Title: Asserting Error Conditions
207
> ### Aliases: assertCondition
207
> ### Aliases: assertCondition assertWarning assertError
208
> ### Keywords: programming error
208
> ### Keywords: programming error
209
> 
209
> 
210
> ### ** Examples
210
> ### ** Examples
211
> 
211
> 
-
 
212
>   assertError(sqrt("abc"))
-
 
213
>   assertWarning(matrix(1:8, 4,3))
-
 
214
> 
212
> assertCondition( ""-1 ) # ok, as it signals a "condition"
215
>   assertCondition( ""-1 ) # ok, any condition would satisfy this
213
> 
216
> 
214
> try( assertCondition(sqrt(2), "warning") )
217
> try( assertCondition(sqrt(2), "warning") )
215
Error in assertCondition(sqrt(2), "warning") : 
218
Error in assertCondition(sqrt(2), "warning") : 
216
  Failed to get expected warning in evaluating sqrt(2)
219
  Failed to get warning in evaluating sqrt(2)
217
> ## .. Failed to get expected warning in evaluating sqrt(2)
220
> ## .. Failed to get warning in evaluating sqrt(2)
218
>      assertCondition(sqrt("abc"), "error")   # ok
221
>      assertCondition(sqrt("abc"), "error")   # ok
219
> try( assertCondition(sqrt("abc"), "warning") )# -> error: had no warning
222
> try( assertCondition(sqrt("abc"), "warning") )# -> error: had no warning
220
Error in assertCondition(sqrt("abc"), "warning") : 
223
Error in assertCondition(sqrt("abc"), "warning") : 
221
  Got simpleError (non-numeric argument to mathematical function) in evaluating sqrt("abc"); expected warning
224
  Got simpleError in evaluating sqrt("abc"); wanted warning
222
> ## verbose ==> show error message additionally:
-
 
223
>      assertCondition(sqrt("abc"), verbose=TRUE, "error")
225
>      assertCondition(sqrt("abc"), "error") 
224
Asserted error: non-numeric argument to mathematical function
226
>   ## identical to assertError() call above
225
> 
227
> 
226
> assertCondition(matrix(1:5, 2,3), "warning")
228
> assertCondition(matrix(1:5, 2,3), "warning")
227
> try( assertCondition(matrix(1:8, 4,3), "error") )
229
> try( assertCondition(matrix(1:8, 4,3), "error") )
228
Error in assertCondition(matrix(1:8, 4, 3), "error") : 
230
Error in assertCondition(matrix(1:8, 4, 3), "error") : 
229
  Got simpleWarning (data length [8] is not a sub-multiple or multiple of the number of columns [3]) in evaluating matrix(1:8, 4, 3); expected error
231
  Got simpleWarning in evaluating matrix(1:8, 4, 3); wanted error
230
> ## .. Failed to get expected error ....
232
> ## .. Failed to get expected error ....
231
> 
233
> 
232
> ## either warning or worse:
234
> ## either warning or worse:
233
> assertCondition(matrix(1:8, 4,3), verbose=TRUE, "error","warning") # OK
235
> assertCondition(matrix(1:8, 4,3), "error","warning") # OK
234
Asserted warning: data length [8] is not a sub-multiple or multiple of the number of columns [3]
-
 
235
> assertCondition(matrix(1:8, 4, 3), "warning", "error") # ditto
236
> assertCondition(matrix(1:8, 4, 3), "warning") # OK 
236
> 
237
> 
237
> ## when both are signalled:
238
> ## when both are signalled:
238
> ff <- function() { warning("my warning"); stop("my error") }
239
> ff <- function() { warning("my warning"); stop("my error") }
239
>     assertCondition(ff(), "warning")
240
>     assertCondition(ff(), "warning")
-
 
241
> ## but assertWarning does not allow an error to follow
-
 
242
> try(assertWarning(ff()))
-
 
243
Error in assertWarning(ff()) : 
-
 
244
  Got warning in evaluating ff(), but also an error
240
>     assertCondition(ff(), "error")          # ok
245
>     assertCondition(ff(), "error")          # ok
241
> assertCondition(ff(), "error", "warning") # ok (quietly, catching warning)
246
> assertCondition(ff(), "error", "warning") # ok (quietly, catching warning)
242
> 
247
> 
243
> ## assert that assertC..() does not assert [and use *one* argument only]
248
> ## assert that assertC..() does not assert [and use *one* argument only]
244
> assertCondition( assertCondition(sqrt( 2   ), "warning") )
249
> assertCondition( assertCondition(sqrt( 2   ), "warning") )
245
> assertCondition( assertCondition(sqrt("abc"), "warning"), "error")
250
> assertCondition( assertCondition(sqrt("abc"), "warning"), "error")
246
> assertCondition( assertCondition(matrix(1:8, 4,3), "error"),
251
> assertCondition( assertCondition(matrix(1:8, 4,3), "error"),
247
+                 "error", verbose=TRUE)
252
+                 "error")
248
Asserted error: Got simpleWarning (data length [8] is not a sub-multiple or multiple of the number of columns [3]) in evaluating matrix(1:8, 4, 3); expected error
-
 
249
> 
253
> 
250
> 
254
> 
251
> 
255
> 
252
> cleanEx()
256
> cleanEx()
253
> nameEx("bibstyle")
257
> nameEx("bibstyle")
Line 283... Line 287...
283
+     pages = "211-252"))
287
+     pages = "211-252"))
284
> 
288
> 
285
> bibstyle("unsorted", sortKeys = function(refs) seq_along(refs),
289
> bibstyle("unsorted", sortKeys = function(refs) seq_along(refs),
286
+     fmtPrefix = function(paper) paste0("[", paper$.index, "]"),
290
+     fmtPrefix = function(paper) paste0("[", paper$.index, "]"),
287
+        .init = TRUE)
291
+        .init = TRUE)
288
<environment: 0x3406378>
292
<environment: 0x236fc30>
289
> print(refs, .bibstyle = "unsorted")
293
> print(refs, .bibstyle = "unsorted")
290
[1] R Core Team (2013). _R: A Language and Environment for Statistical
294
[1] R Core Team (2013). _R: A Language and Environment for Statistical
291
Computing_. R Foundation for Statistical Computing, Vienna, Austria.
295
Computing_. R Foundation for Statistical Computing, Vienna, Austria.
292
<URL: http://www.R-project.org>.
296
<URL: http://www.R-project.org>.
293
 
297
 
Line 980... Line 984...
980
> ### Keywords: utilities documentation
984
> ### Keywords: utilities documentation
981
> 
985
> 
982
> ### ** Examples
986
> ### ** Examples
983
> 
987
> 
984
> str(vignetteEngine("Sweave"))
988
> str(vignetteEngine("Sweave"))
985
List of 5
989
List of 6
986
 $ name   : chr "Sweave"
990
 $ name   : chr "Sweave"
987
 $ package: chr "utils"
991
 $ package: chr "utils"
988
 $ pattern: chr "[.][rRsS](nw|tex)$"
992
 $ pattern: chr "[.][rRsS](nw|tex)$"
989
 $ weave  :function (...)  
993
 $ weave  :function (...)  
990
 $ tangle :function (...)  
994
 $ tangle :function (...)  
-
 
995
 $ aspell :List of 2
-
 
996
  ..$ filter : chr "Sweave"
-
 
997
  ..$ control: chr "-t"
991
> 
998
> 
992
> 
999
> 
993
> 
1000
> 
994
> cleanEx()
1001
> cleanEx()
995
> nameEx("writePACKAGES")
1002
> nameEx("writePACKAGES")
Line 1031... Line 1038...
1031
> 
1038
> 
1032
> ### * <FOOTER>
1039
> ### * <FOOTER>
1033
> ###
1040
> ###
1034
> options(digits = 7L)
1041
> options(digits = 7L)
1035
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
1042
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
1036
Time elapsed:  0.471 0.023 0.593 0 0 
1043
Time elapsed:  0.247 0.005 0.254 0 0 
1037
> grDevices::dev.off()
1044
> grDevices::dev.off()
1038
null device 
1045
null device 
1039
          1 
1046
          1 
1040
> ###
1047
> ###
1041
> ### Local variables: ***
1048
> ### Local variables: ***