R names()

Jmnote (토론 | 기여)님의 2019년 4월 18일 (목) 23:22 판 (→‎개요)

1 개요

R names()
  • 객체에 대한 이름들을 얻거나(get) 설정하는(set) R 함수
z <- 1:5
z
## [1] 1 2 3 4 5
names(z) <- letters[1:5]
z
## a b c d e 
## 1 2 3 4 5
names(z) <- NULL
z
## [1] 1 2 3 4 5
str(islands)
##  Named num [1:48] 11506 5500 16988 2968 16 ...
##  - attr(*, "names")= chr [1:48] "Africa" "Antarctica" "Asia" "Australia" ...
names(islands)
##  [1] "Africa"           "Antarctica"       "Asia"             "Australia"       
##  [5] "Axel Heiberg"     "Baffin"           "Banks"            "Borneo"          
##  [9] "Britain"          "Celebes"          "Celon"            "Cuba"            
## [13] "Devon"            "Ellesmere"        "Europe"           "Greenland"       
## [17] "Hainan"           "Hispaniola"       "Hokkaido"         "Honshu"          
## [21] "Iceland"          "Ireland"          "Java"             "Kyushu"          
## [25] "Luzon"            "Madagascar"       "Melville"         "Mindanao"        
## [29] "Moluccas"         "New Britain"      "New Guinea"       "New Zealand (N)" 
## [33] "New Zealand (S)"  "Newfoundland"     "North America"    "Novaya Zemlya"   
## [37] "Prince of Wales"  "Sakhalin"         "South America"    "Southampton"     
## [41] "Spitsbergen"      "Sumatra"          "Taiwan"           "Tasmania"        
## [45] "Tierra del Fuego" "Timor"            "Vancouver"        "Victoria"
z <- list(a = 1, b = "c", c = 1:3)
z
## $a
## [1] 1
## 
## $b
## [1] "c"
## 
## $c
## [1] 1 2 3
names(z)
## [1] "a" "b" "c"
names(z[3])
## [1] "c"

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}