fixedpoint.jp


Rで定義されている短い名前の識別子の一覧 (2020-03-27)

Rで既定で有効になっているbaseパッケージには、cという名前の関数があります。これは連結(concatenate)ないし結合(combine)のための関数です。また、tという名前の関数があります。これは転置(transpose)関数です。

このように短い名前の識別子がもともと定義されている場合でも、変数名として別の値を束縛することは可能ですが、紛らわしいコードになる恐れがあります。そこで、気付かずに変数名に使ってしまわないように、3文字以下のアルファベットからなる既定で定義済みの識別子を以下のように一覧してみました。

short-predefined-identifiers-in-r.txt
% R 

R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin19.3.0 (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.

  Natural language support but running in an English locale

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.

> Map(function(p) Filter(function(x) grepl('^\\w{1,3}$', x), ls(sprintf('package:%s', p))), c('base', getOption('defaultPackages')))
$base
 [1] "abs" "all" "any" "Arg" "by"  "c"   "cat" "col" "cos" "cut" "det" "dim"
[13] "dir" "exp" "F"   "for" "gc"  "get" "gl"  "I"   "if"  "Im"  "log" "ls" 
[25] "Map" "max" "min" "Mod" "pi"  "q"   "qr"  "raw" "Re"  "rep" "rev" "rle"
[37] "rm"  "row" "seq" "sin" "sub" "sum" "svd" "t"   "T"   "tan" "try" "unz"
[49] "url" "xor"

$datasets
[1] "BOD" "co2" "CO2" "lh"  "npk"

$utils
[1] "de"  "fix" "nsl" "str" "tar" "vi"  "zip"

$grDevices
 [1] "bmp" "cm"  "hcl" "hsv" "pdf" "png" "rgb" "svg" "x11" "X11"

$graphics
[1] "box" "bxp" "lcm" "par" "pie" "rug"

$stats
 [1] "acf" "AIC" "aov" "ar"  "ave" "BIC" "C"   "ccf" "cor" "cov" "D"   "df" 
[13] "dt"  "end" "fft" "glm" "hat" "IQR" "lag" "lm"  "mad" "nlm" "nls" "pf" 
[25] "ppr" "pt"  "qf"  "qt"  "rf"  "rt"  "sd"  "SSD" "stl" "ts"  "tsp" "var"

$methods
[1] "as"  "el"  "is"  "new" "Ops"

> 

該当するものが100以上あることが分かります。また、小文字だけでなく、大文字のCTも定義済みです。


© 2006-2023 fixedpoint.jp