作成日 2015-07-30
最終更新日
名前属性
アトミックベクトルに、属性を使用して名前を付けることができます。名前を付けるには、属性のヘルパー関数names()を使用します。
名前属性を付ける
> die <- c(1, 2, 3, 4, 5, 6)
> die
[1] 1 2 3 4 5 6
> names(die)
NULL
> names(die) <- c("one", "two", "three", "four", "five", "six")
> names(die)
[1] "one" "two" "three" "four" "five" "six"
> attributes(die)
$names
[1] "one" "two" "three" "four" "five" "six"
>
名前属性を変更する
名前を変更するには、nanesに新しい名前を割り当てます。
> names(die) <- c("uno", "dos", "tres", "cuatro", "cinco", "seis")
> names(die)
[1] "uno" "dos" "tres" "cuatro" "cinco" "seis"
>
名前属性を削除する
名前属性を取り除くには、NULLを割り当てます。
> names(die) [1] "uno" "dos" "tres" "cuatro" "cinco" "seis" > names(die) <- NULL > names(die) NULL >