I have
vetor <- c(1,2,3)
data <- data.frame(id=c(\'a\', \'b\', \'a\', \'c\', \'a\'))
I need a data.frame output that match each vecto
Here's an answer I found that follows the "mathematical.coffee" tip:
vector1 <- c('b','a','a','c','a','a') # 3 elements to be labeled: a, b and c
labels <- factor(vector1, labels= c('char a', 'char b', 'char c') )
data.frame(vector1, labels)
The only thing we need to observe is that in the factor(vector1,...)
function, vector1
will be ordered and the labels must follow that order correctly.