1
2R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
3Copyright (C) 2020 The R Foundation for Statistical Computing
4Platform: x86_64-apple-darwin17.0 (64-bit)
5
6R is free software and comes with ABSOLUTELY NO WARRANTY.
7You are welcome to redistribute it under certain conditions.
8Type 'license()' or 'licence()' for distribution details.
9
10R is a collaborative project with many contributors.
11Type 'contributors()' for more information and
12'citation()' on how to cite R or R packages in publications.
13
14Type 'demo()' for some demos, 'help()' for on-line help, or
15'help.start()' for an HTML browser interface to help.
16Type 'q()' to quit R.
17
18> NAME <- "subset"
19> source(file.path('_helper', 'init.R'))
20>
21> A <- B <- letters[1:5]
22> B[2] <- "B"
23> B[6] <- "F"
24>
25> # - subset ---------------------------------------------------------------------
26>
27> local({
28+   old.opt <- options(diffobj.style=StyleRaw())
29+   on.exit(options(old.opt))
30+   a0 <- all.equal(
31+     c(as.character(diffChr(A, B)[1:3])),
32+     c("< A          > B        ", "@@ 1,5 @@    @@ 1,6 @@  ", "  a            a        ")
33+
34+   )
35+   a <- all.equal(
36+     c(as.character(diffChr(A, B)[1])), c(as.character(head(diffChr(A, B), 1)))
37+   )
38+   b <- all.equal(
39+     c(as.character(diffChr(A, B)[7:8])), c(as.character(tail(diffChr(A, B), 2)))
40+   )
41+   c(a0, a, b)
42+ })
43[1] TRUE TRUE TRUE
44> # - subset errors --------------------------------------------------------------
45>
46> diff <- diffChr(A, B)
47> try(diff[NA_real_]) # "contain NAs or both positive"
48Error in .local(x, i, ...) :
49  `i` may not contain NAs or both positive and negative indices
50> try(diff[c(-1, 1)]) # "contain NAs or both positive"
51Error in .local(x, i, ...) :
52  `i` may not contain NAs or both positive and negative indices
53> try(head(diff, 1, 2)) # "does not support arguments"
54Error in .local(x, ...) :
55  This method does not support arguments other than `x` or `n`
56> try(head(diff, NA)) # "must be integer"
57Error in .local(x, ...) : `n` must be integer(1L) and not NA
58> try(head(diff, 1:3)) # "must be integer"
59Error in .local(x, ...) : `n` must be integer(1L) and not NA
60> try(tail(diff, 1:3)) # "must be integer"
61Error in .local(x, ...) : `n` must be integer(1L) and not NA
62> try(tail(diff, 1, 2)) # "does not support arguments"
63Error in .local(x, ...) :
64  This method does not support arguments other than `x` or `n`
65>
66>
67>
68> proc.time()
69   user  system elapsed
70  1.519   0.155   1.873
71