-1

I have now 5 scale from 2 to 10, but values bigger than 6 are not detected. So I would like to create new scale : 2,3, and 4+ (containing 4,5,6). I don't know how to formulate the condition..

Its an ordered factor, levels=2:10

RInatM
  • 1,208
  • 1
  • 17
  • 39
  • Yes, i tried, bud i dont understand the universal syntax. Whene I have for ex : 2 3 5 2 6 3 2 2 5 3 6 - used levels are 2 to 6 and I want 2,3, "and more" as special categorie... – Anna Smržová Apr 08 '16 at 12:00
  • ah, now I understand - look here - http://stackoverflow.com/questions/9604001/grouping-2-levels-of-a-factor-in-r – RInatM Apr 08 '16 at 12:09

1 Answers1

1

In case of small number of levels, using levels <- like here

> x = factor(c(1:5))
> str(x)
Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5
> levels(x) <- c("1", "2", "3", "4+", "4+")
> x
[1] 1  2  3  4+ 4+
Levels: 1 2 3 4+

If you have many levels, look here

Community
  • 1
  • 1
RInatM
  • 1,208
  • 1
  • 17
  • 39
  • Thank you for your willingness, i really tried but it doesnt work directly in factor description...thx :) – Anna Smržová Apr 08 '16 at 12:40
  • maybe it would be easier for others to help, if you edit your question and describe, what you are trying to achive If you are interested in descriptions, just use as.character(x) if you need just cut all your data at certain level, use x[x>4] <- 4 – RInatM Apr 08 '16 at 12:44