I am trying to create a loop in R that allows me to change the value of an object within the loop. 
Below is an easy example to point out what exactly I mean by this. Print(x) stands for a rather extensive bulk of code, in which the value of x is needed for certain computations. However, while solution #1 works on paper, it is not usable in this context (because of sub loops). Is there any way to design a loop in R that resembles solution #2? Thanks a lot in advance! 

```
1> x <- 1           
2> while (x == 1)
3> {
4> print(x)
5> x <- 2
6> print(x)
7> x <- 3
8> print(x)
9> x <- 4
10> print(x)
11> if (x == 4)
12> break
13> }

```

Output
1
2
3
4

```
1> x <- 1
2> while (x == 1 || x == 2 || x == 3 || x == 4)
3> {
4> print (x)
5> x <- 2
   #jump to line 2, ignore line 5, proceed with line 6
6> x <- 3
   #jump to line 2, ignore line 6, proceed with line 7
7> x <- 4
   #jump to line 2, ignore line 7, proceed with line 8
8> if (x == 4)
9> break
10> }

```

Output
1
2
3
4