octmode

0th

Percentile

Display Numbers in Octal

Convert or print integers in octal format, with as many digits as are needed to display the largest, using leading zeroes as necessary.

Keywords
utilities, print
Usage
as.octmode(x)
"as.character"(x, ...)
"format"(x, width = NULL, ...)
"print"(x, ...)
Arguments
x
An object, for the methods inheriting from class "octmode".
width
NULL or a positive integer specifying the minimum field width to be used, with padding by leading zeroes.
...
further arguments passed to or from other methods.
Details

Class "octmode" consists of integer vectors with that class attribute, used merely to ensure that they are printed in octal notation, specifically for Unix-like file permissions such as 755. Subsetting ([) works too.

If width = NULL (the default), the output is padded with leading zeroes to the smallest width needed for all the non-missing elements.

as.octmode can convert integers (of type "integer" or "double") and character vectors whose elements contain only digits 0-7 (or are NA) to class "octmode".

There is a ! method and |, & and xor methods: these recycle their arguments to the length of the longer and then apply the operators bitwise to each element.

See Also

These are auxiliary functions for file.info.

hexmode, sprintf for other options in converting integers to octal, strtoi to convert octal strings to integers.

Aliases
  • as.octmode
  • format.octmode
  • print.octmode
  • as.character.octmode
  • [.octmode
  • !.octmode
  • |.octmode
  • &.octmode
  • xor.octmode
  • octmode
Examples
library(base) (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
Documentation reproduced from package base, version 3.1.3, License: Part of R 3.1.3

Community examples

Looks like there are no examples yet.