Search notes:

R function: setNames

setNames(v, n) is a shorthand form for names(v) <- n.
vec_a <- setNames(c( 42, 99, 3, 18, 5), c('val_1', 'val_2', 'val_3', 'val_4', 'val_5'))

vec_a
#
# val_1 val_2 val_3 val_4 val_5 
#    42    99     3    18     5 

vec_b <- c( 5, 27, 13, 48, 19)
names(vec_b) <- c('val_1', 'val_2', 'val_3', 'val_4', 'val_5')

vec_b
#
# val_1 val_2 val_3 val_4 val_5 
#     5    27    13    48    19
Github repository about-r, path: /functions/setNames.R

See also

setNames() is used on objects where the names attribute makes sense.

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...', 1745461698, '3.15.204.106', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/setNames(54): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78