Attributes¶
onetofour <- c(first=1,second=2,third=3,fourth=4)
attributes(onetofour)
$names
[1] "first" "second" "third" "fourth"
set.seed(42)
satisfaction <- sample(1:4,size=20,replace=TRUE)
satisfaction <- ordered(satisfaction,
levels=1:4,
labels=c(
"not at all",
"low",
"medium",
"high"))
attributes(satisfaction)
$levels
[1] "not at all" "low" "medium" "high"
$class
[1] "ordered" "factor"
attr(satisfaction,"levels")
[1] "not at all" "low" "medium" "high"
levels(satisfaction)
[1] "not at all" "low" "medium" "high"
attr(satisfaction,"class")
[1] "ordered" "factor"
class(satisfaction)
[1] "ordered" "factor"
- R file: attributes.R
- Rmarkdown file: attributes.Rmd
- Jupyter notebook file: attributes.ipynb
- Interactive version of the Jupyter notebook (shuts down after 60s):
- Interactive version of the Jupyter notebook (sign in required):