what would it mean to 'label' a dataset, and in what context is that useful ?
do you perhaps just mean the name that its known by ?
you could indeed add arbitrary attributes, that you could access ... but is this worthwhile ?
attributes wont often come along for the ride when you use transformations, so they can be pretty fragile...
unless you want to get into making your own classes, but I think this would open up a big can of worms.
Something I do very occasionally is to keep related objects in a common list.
mydata <- head(iris)
attr(mydata,
"mylabel") <- "This is to document that this data.frame was made by head(iris)"
mydata
attr(mydata,"mylabel")
attributes(mydata)
mydata2 <- select(mydata,
Petal.Length)
mydata2
attr(mydata2,"mylabel")
mydata2 <- mydata
attr(mydata2,"mylabel")
mydata2 <- select(mydata2,
Petal.Length)
attr(mydata2,"mylabel")
mydata3 <- list(Note="The data.frame came from head(iris",
df = head(iris))
mydata3