| 1 |
require("sfsmisc") |
| 2 |
|
| 3 |
options(warn=2) |
| 4 |
AsciiToInt(LETTERS) # gave '.. embedded nul ..' warning |
| 5 |
|
| 6 |
## just for fun -- typically shows "iso-latin1 charset |
| 7 |
cat(chars8bit(1:255),"\"\n") |
| 8 |
|
| 9 |
## Checking the new 'ndigits' default argument for digitsBase(): |
| 10 |
ee <- 0:30 |
| 11 |
for(base in 2:64) |
| 12 |
stopifnot((be <- base^ee) > 0, any(ok <- be < 2^52), |
| 13 |
ee == floor(1e-9+ log(be, base)), |
| 14 |
0 == as.integer(digitsBase(0, base=base)), # failed |
| 15 |
be[ok] == as.integer(digitsBase(be[ok], base=base))) |
| 16 |
## failed, e.g. for 3^5, in sfsmisc <= 1.0-22 |
| 17 |
|
| 18 |
## Tests for is.whole (taken from the examples) |
| 19 |
set.seed(307) |
| 20 |
a <- array(runif(24), dim = c(2, 3, 4)) |
| 21 |
a[4:8] <- 4:8 |
| 22 |
m <- matrix(runif(12), 3, 4) |
| 23 |
m[2:4] <- 2:4 |
| 24 |
v <- complex(real = seq(0.5, 1.5, by = 0.1), |
| 25 |
imaginary = seq(2.5, 3.5, by = 0.1)) |
| 26 |
|
| 27 |
## Find whole entries |
| 28 |
stopifnot(identical(is.whole(a), a == round(a)), |
| 29 |
identical(is.whole(m), m == round(m)), |
| 30 |
which(is.whole(v)) == 6) |
| 31 |
|
| 32 |
## Numbers of class integer are always whole |
| 33 |
stopifnot(is.whole(dim(a)), is.whole(length(v)), is.whole(-1L)) |
| 34 |
|
| 35 |
|
| 36 |
## From: Liping Seng <[email protected]> |
| 37 |
## Subject: Bug with integrate.xy()? |
| 38 |
## Date: Wed, 7 Jun 2017 12:24:12 +0000 |
| 39 |
## MM simplified |
| 40 |
set.seed(1776) |
| 41 |
y <- rnorm(200) |
| 42 |
fit <- density(y, bw = 0.3773427, n=1024, kernel="epanechnikov") |
| 43 |
integrate.xy(fit$x, fit$y, min(fit$x), 1.7927854, xtol=3.16228e-7) |
| 44 |
## Fixed (2017-06-08) |
| 45 |
## Error in seq.default(a, length = max(0, b - a - 1)) : |
| 46 |
## 'length.out' must be a non-negative number |