Search notes:

R function: names

#
#    S.a. ../examples/having_a_look_at_data.R
#

l <- list(foo = 42, bar = 1:10, baz = 1:3 )

n <- names(l)
n
# [1] "foo" "bar" "baz"

# ----------------------------

v <- 1:4
names(v) <- c("one", "two", "three", "four")
v
#   one   two three  four
#     1     2     3     4

v["two"]
# two
#   2

v[c('two', 'four')]
# two four
#   2    4

cat("\n\n\n")


w <- read.csv("data.csv")
names(w)
# [1] "col_1" "col_2" "col_3"
Github repository about-r, path: /functions/names.R

See also

setNames()
names() is used on objects where the names attribute makes sense.
Using names to add label bars in a bar plot.
Index to (some) R functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745458843, '3.149.250.24', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/names(78): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78