Search notes:

R function: attributes

Access an object's attributes.
#
#  S.a. -> attr()
#       ../examples/having_a_look_at_data.R
#

attributes(42)
# NULL

attributes("Foo")
# NULL

attributes(TRUE)
# NULL

attributes(c(1:10))
# NULL

attributes(factor(c(1:10)))
# $levels
#  [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10"
# 
# $class
# [1] "factor"

csv_data <- read.csv("data.csv")
attributes(csv_data)
# $names
# [1] "col_1" "col_2" "col_3"
# 
# $class
# [1] "data.frame"
# 
# $row.names
# [1] 1 2

vec <- 1:4
names(vec) <- c('a', 'b', 'c', 'd')
attributes(vec)
# $names
# [1] "a" "b" "c" "d"

# Obviously, dim(..) removes the names attribute:
dim  (vec) <- c(2,2)
attributes(vec)
# $dim
# [1] 2 2

dummy <- factor(vec)
attributes(vec)
# $dim
# [1] 2 2
Github repository about-r, path: /functions/attributes.R

See also

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