Hello,
I'm new to R and still trying to figure out things. One of my homework assignments is to create a While Loop. Here are my instructions:
Create a new rscript file called (exactly) Challenge32C.R. Make sure you save it in the /workspace directory. Write a While Loop statement that prints all numbers to the console from within the while loop from -1 to 1 in .25 increments.
Here is the code I wrote:
#Control Flow -- WHILE LOOP
die1<- -1.25 #set control variable
while (die1<-1.25) { #check condition of control variable
vd1d2<-c((die1+.25),(die1+.5),(die1+.75),(die1+1),(die1+1.25),(die1+1.5),(die1+1.75),(die1+2)) #create vector
print(vd1d2) #print vector as you process each die1
die1<-die1+.25 #increment control variable
}
I know I'm on the right track, but something is off and I have no idea what. I've tried making minor changes but still don't seem closer to the answer. I keep getting the numbers "[1] 1.50 1.75 2.00 2.25 2.50 2.75 3.00 3.25" repeating over and over and over.
Any insight you have, I'd really appreciate. Thank you!