Question: I'm having a problem with my switch statement, sorry if this is trivial, I'm very new! At the switch statement I'm getting the error :

> 
> Syntax error on tokens, Label expected instead.
> 
> 
> 

At each of the cases I'm getting the error :

> 
> Syntax error on token "case", assert expected
> 
> 
> 

Both `productNumber` and `numberOfProduct` are type int input by the user. `total` and `currentTotal` are type `double`.

```
Switch (productNumber) //problem occurs here, at the switch statement and at each case
{
    case 1:
        currentTotal = numberOfProduct * 2.98;
        total += currentTotal;
        break;

    case 2:
        currentTotal = numberOfProduct * 4.50;
        total += currentTotal;
        break;

    case 3:
        currentTotal = numberOfProduct * 9.98;
        total += currentTotal;
        break;

    case 4://
        currentTotal = numberOfProduct * 4.49;
        total += currentTotal;
        break;

    case 5:
        currentTotal = numberOfProduct * 6.87;
        total += currentTotal;
        break;

    default:
        System.out.println("The number entered is not a known product number. Known product numbers are 1, 2, 3, 4, and 5.");
        --count;
}

```

Answer: 
You should use `ifelse`:

```
transform(data1,
          mutation = ifelse (genotype == "B3",  "wt",
          ifelse (genotype %in% c("ein9","ein194"),
                  "phyB", "hy2")))

#      internode_length treatment genotype mutation
# 1           98.165       sun       B3       wt
# 2          116.633       sun       B3       wt
# 3          103.474       sun     ein9     phyB
# 4          120.683       sun       B3       wt
# 5          109.128       sun   ein194     phyB
# 6          129.076       sun       A2      hy2

```
You could also do this without using `ifelse`

```
  v1 <- factor(df$genotype)
  v1
  #[1] B3     B3     ein9   B3     ein194 A2    
  #Levels: A2 B3 ein194 ein9

```

Change the levels to the one you wanted. Here `ein194` and `ein9` should be `phyB`.

```
  levels(v1) <-  c("hy2", "wt", "phyB", "phyB")
  df$new_column <- as.character(v1)
   df
  #   internode_length treatment genotype new_column
  #1           98.165       sun       B3         wt
  #2          116.633       sun       B3         wt
  #3          103.474       sun     ein9       phyB
  #4          120.683       sun       B3         wt
  #5          109.128       sun   ein194       phyB
  #6          129.076       sun       A2        hy2

```

### data

```
 df <- structure(list(internode_length = c(98.165, 116.633, 103.474, 
 120.683, 109.128, 129.076), treatment = c("sun", "sun", "sun", 
 "sun", "sun", "sun"), genotype = c("B3", "B3", "ein9", "B3", 
 "ein194", "A2")), .Names = c("internode_length", "treatment", 
"genotype"), row.names = c("1", "2", "3", "4", "5", "6"), class = "data.frame")

```