0

I am trying to combine classes, and can't figure out how.

I am working with a large data set

library("ALL"); data(ALL, package = "ALL");

and normally load the indicator like this:

 allB <- ALL[,which(ALL$BT %in% c("B","B1","B2", "B3","B4"))]

and that separates it into 5, but I want to combine the B3 and B4

I have tried a few different things,

b1 <- ALL[,which(ALL$BT %in% c("B1"))] #select patients
b2 <- ALL[,which(ALL$BT %in% c("B2"))]
b34 <- ALL[,which(ALL$BT %in% c("B3","B4"))]
w <- c(b1,b2,b34)

allb <- ALL[,which(ALL$BT %in% c("B1","B2", c("B3","B4")))] 

allb <- ALL[,which(ALL$BT %in% c("B1","B2","B3|B4"))] 

But none of them work

data set info :

ALL$BT
[1] B2 B2 B4 B1 B2 B1 B1 B1 B2 B2 B3 B3 B3 B2 B3 B  B2 B3 B2 B3 B2 B2 B2 B1 B1 B2 B1 B2 B1 B2 B  B  B2 B2 B2 B1 B2 B2 B2 B2 B2 B4 B4
[44] B2 B2 B2 B4 B2 B1 B2 B2 B3 B4 B3 B3 B3 B4 B3 B3 B1 B1 B1 B1 B3 B3 B3 B3 B3 B3 B3 B3 B1 B3 B1 B4 B2 B2 B1 B3 B4 B4 B2 B2 B3 B4 B4
[87] B4 B1 B2 B2 B2 B1 B2 B  B  T  T3 T2 T2 T3 T2 T  T4 T2 T3 T3 T  T2 T3 T2 T2 T2 T1 T4 T  T2 T3 T2 T2 T2 T2 T3 T3 T3 T2 T3 T2 T 
Levels: B B1 B2 B3 B4 T T1 T2 T3 T4

allB$BT
 [1] B2 B2 B4 B1 B2 B1 B1 B1 B2 B2 B3 B3 B3 B2 B3 B  B2 B3 B2 B3 B2 B2 B2 B1 B1 B2 B1 B2 B1 B2 B  B  B2 B2 B2 B1 B2 B2 B2 B2 B2 B4 B4 B2
[45] B2 B2 B4 B2 B1 B2 B2 B3 B4 B3 B3 B3 B4 B3 B3 B1 B1 B1 B1 B3 B3 B3 B3 B3 B3 B3 B3 B1 B3 B1 B4 B2 B2 B1 B3 B4 B4 B2 B2 B3 B4 B4 B4 B1
[89] B2 B2 B2 B1 B2 B  B 
Levels: B B1 B2 B3 B4 T T1 T2 T3 T4

ALL
ExpressionSet (storageMode: lockedEnvironment)
assayData: 12625 features, 128 samples 
  element names: exprs 
Jamie Leigh
  • 359
  • 1
  • 4
  • 18
  • You may be confused with the `%in%` operator. It is only testing for each element of the left-hand side whether it exists in the right-hand side. There is no combination going on. If you posted the result that you 'should' be getting then someone will be able to show the way. – Pierre L Dec 14 '16 at 20:12
  • The term "class" is improperly used here at least as far as R terminology is constituted. In R the data type (or class) which is used to represent categorical data is the "factor"-class and it's values are "levels". – IRTFM Dec 14 '16 at 21:22
  • It's what my teacher was calling it. I kept getting confused because I was sure class was something different – Jamie Leigh Dec 15 '16 at 03:16

1 Answers1

0

I must have been phrasing it wrong, I wanted to rename the levels

levels(allB$BT)[levels(allB$BT)=="B3"] <- "B34"
levels(allB$BT)[levels(allB$BT)=="B4"] <- "B34"

Worked

allB$BT
 [1] B2  B2  B34 B1  B2  B1  B1  B1  B2  B2  B34 B34 B34 B2  B34 B2  B34 B2  B34 B2  B2  B2  B1  B1  B2  B1  B2  B1  B2  B2  B2  B2  B1 
[34] B2  B2  B2  B2  B2  B34 B34 B2  B2  B2  B34 B2  B1  B2  B2  B34 B34 B34 B34 B34 B34 B34 B34 B1  B1  B1  B1  B34 B34 B34 B34 B34 B34
[67] B34 B34 B1  B34 B1  B34 B2  B2  B1  B34 B34 B34 B2  B2  B34 B34 B34 B34 B1  B2  B2  B2  B1  B2 
Levels: B B1 B2 B34 T T1 T2 T3 T4
Jamie Leigh
  • 359
  • 1
  • 4
  • 18