I am wondering if, given a named vector, if it is possible to print (or display in the R console) only the values of the vector without deleting the names.
# EXAMPLE
v <- (1:5)
names(v) <- LETTERS[1:5]
print(v)
# RESULT:
# A B C D E
# 1 2 3 4 5
# RESULT I AM SEEKING
# [1] 1 2 3 4 5
I am able to get the result I am looking for using the following function.
However, is there a better or more direct way of printing only the values of a named vector?
print.n <- function (obj) {
names(obj) <- NULL
print(obj)
}
print.n(v)
# [1] 1 2 3 4 5
Thanks.
Try
unname():