octmode {base}  R Documentation 
Integers which are displayed in octal (base8 number system) format, with as many digits as are needed to display the largest, using leading zeroes as necessary.
Arithmetic works as for integers, and noninteger valued mathematical functions typically work by truncating the result to integer.
as.octmode(x)
## S3 method for class 'octmode'
as.character(x, keepStr = FALSE, ...)
## S3 method for class 'octmode'
format(x, width = NULL, ...)
## S3 method for class 'octmode'
print(x, ...)
x 
an object, for the methods inheriting from class 
keepStr 
a 
width 

... 
further arguments passed to or from other methods. 
"octmode"
objects are integer vectors with that class
attribute, used primarily to ensure that they are printed in octal
notation, specifically for Unixlike file permissions such as
755
. Subsetting ([
) works too, as do arithmetic or
other mathematical operations, albeit truncated to integer.
as.character(x)
drops all attributes
(unless when
keepStr=TRUE
where it keeps, dim
, dimnames
and
names
for back compatibility) and converts each entry individually, hence with no
leading zeroes, whereas in format()
, when width = NULL
(the
default), the output is padded with leading zeroes to the smallest width
needed for all the nonmissing elements.
as.octmode
can convert integers (of type "integer"
or
"double"
) and character vectors whose elements contain only
digits 07
(or are NA
) to class "octmode"
.
There is a !
method and methods for 
and
&
:
these recycle their arguments to the length of the longer and then
apply the operators bitwise to each element.
These are auxiliary functions for file.info
.
hexmode
, sprintf
for other options in
converting integers to octal, strtoi
to convert octal
strings to integers.
(on < as.octmode(c(16, 32, 127:129))) # "020" "040" "177" "200" "201"
unclass(on[3:4]) # subsetting
## manipulate file modes
fmode < as.octmode("170")
(fmode  "644") & "755"
umask < Sys.umask(NA) # depends on platform
c(fmode, "666", "755") & !umask
om < as.octmode(1:12)
om # print()s via format()
stopifnot(nchar(format(om)) == 2)
om[1:7] # *no* leading zeroes!
stopifnot(format(om[1:7]) == as.character(1:7))
om2 < as.octmode(c(1:10, 60:70))
om2 # prints via format() > with 3 octals
stopifnot(nchar(format(om2)) == 3)
as.character(om2) # strings of length 1, 2, 3
## Integer arithmetic (remaining "octmode"):
om^2
om * 64
om
(fac < factorial(om)) # !1, !2, !3, !4 .. in hexadecimals
as.integer(fac) # indeed the same as factorial(1:12)