/usr/share/doc/r-cran-data.table/tests/autoprint.Rout.save is in r-cran-data.table 1.10.4-3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> require(data.table)
Loading required package: data.table
> # Tests the suppression of := output
> # Since this tests autoprinting at the console, it needs to use the .Rout.save mechanism in R CMD check
> DT = data.table(a=1:2) # Should print at console?
> DT # yes
a
1: 1
2: 2
> DT[1] # yes
a
1: 1
> DT[2,a:=3L] # no
> DT # yes
a
1: 1
2: 3
> DT[FALSE,a:=3L] # no
> DT[a==4L,a:=5L] # no
> DT[a %in% 4:8, a:=5L] # no
> DT # yes
a
1: 1
2: 3
> print(DT[2,a:=4L]) # no
> print(DT) # yes
a
1: 1
2: 4
> if (TRUE) DT[2,a:=5L] # no. used to print before v1.9.5
> if (TRUE) if (TRUE) DT[2,a:=6L] # no. used to print before v1.9.5
> (function(){DT[2,a:=5L];NULL})() # print NULL
NULL
> DT # no (from v1.9.5+). := suppresses next auto print (can't distinguish just "DT" symbol alone at the prompt)
> DT # yes. 2nd time needed, or solutions below
a
1: 1
2: 5
> (function(){DT[2,a:=5L];NULL})() # print NULL
NULL
> DT[] # yes. guaranteed print
a
1: 1
2: 5
> (function(){DT[2,a:=5L];NULL})() # print NULL
NULL
> print(DT) # no. only DT[] is guaranteed print from v1.9.6 and R 3.2.0
> (function(){DT[2,a:=5L][];NULL})() # print NULL
NULL
> DT # yes. i) function needs to add [] after last one, so that "DT" alone is guaranteed anyway
a
1: 1
2: 5
> (function(){DT[2,a:=5L];DT[];NULL})() # print NULL
NULL
> DT # yes. ii) or as a separate DT[] after the last := inside the function
a
1: 1
2: 5
> DT2 = data.table(b=3:4) # no
> (function(){DT[2,a:=6L];DT2[1,b:=7L];NULL})()
NULL
> DT # yes. last := was on DT2 not DT
a
1: 1
2: 6
> {DT[2,a:=6L];invisible()} # no
> print(DT) # no
> (function(){print(DT[2,a:=7L]);print(DT);invisible()})() # yes*2
a
1: 1
2: 7
a
1: 1
2: 7
> {print(DT[2,a:=8L]);print(DT);invisible()} # yes*1 Not within function so as at prompt
a
1: 1
2: 8
> DT[1][,a:=9L] # no (was too tricky to detect that DT[1] is a new object). Simple rule is that := always doesn't print
> DT[2,a:=10L][1] # yes
a
1: 1
> DT[1,a:=10L][1,a:=10L] # no
> DT[,a:=as.integer(a)] # no
> DT[1,a:=as.integer(a)] # no
> DT[1,a:=10L][] # yes. ...[] == oops, forgot print(...)
a
1: 10
2: 10
>
> # Test that error in := doesn't suppress next valid print, bug #2376
> tryCatch(DT[,foo:=ColumnNameTypo], error=function(e) e$message) # error: not found.
[1] "object 'ColumnNameTypo' not found"
> DT # yes
a
1: 10
2: 10
> DT # yes
a
1: 10
2: 10
>
>
> proc.time()
user system elapsed
3.14 0.10 3.22
|