Questions tagged as 'factors'

2
answers

Error converting numbers. How to convert factors to numbers?

In the following example: dados <- data.frame(x=c("11", "10", "20", "15"), y=c("25", "30", "35", "40")) dados x y 1 11 25 2 10 30 3 20 35 4 15 40 When trying to transform the variable x into number, instead of 11, 10, 20 15 ap...
asked by 14.03.2014 / 06:32
2
answers

Reorder the categories in a data frame

When we import data into R it sorts the categories alphabetically. How do I change this order? Suppose it is the following data: df <- data.frame(categorias=c("Muito baixa","Baixa","Média","Alta","Muito alta"), valores=s...
asked by 02.04.2014 / 19:17
1
answer

How to remove unused categories in the database

Suppose I have the following database: df <- data.frame(categorias=c("A","B","C","D","E"), valores=seq(1:5)) When I make a subset of that date frame the categories I've removed continue. subdf <- subset(df, valores...
asked by 02.04.2014 / 19:07