R programming error

0 votes

How does the speed reduce in this code snippet?

speed <- 64

while (speed > 30) {
  print(paste("Your speed is",speed))
  if ( speed > 48 ) {
    print("Slow down big time!")
    speed <- speed -11
    print(speed)
  } else {
    print("Slow down!")
    speed <- speed -6

  }
}
Apr 2, 2019 in Data Analytics by Sophie may
• 10,100 points
62 views

1 answer to this question.

0 votes
Loop 1: the value of speed is 64, thus, reducing speed by 11 you get --> 53

Loop 2: the value of speed is 53, thus, reducing speed by 11 you get --> 42

Loop 3: value of speed is now 42, which is less than 48, so else is executed, bringing the speed down by 6 --> 36
answered Apr 2, 2019 by Tyrion anex
• 8,550 points

Related Questions In Data Analytics

+3 votes
2 answers

Error: could not find function - R Programming

Yes, Just like @Maverik said, It happens ...READ MORE

answered Aug 22, 2019 in Data Analytics by anonymous
• 32,490 points
18,117 views
0 votes
1 answer

"no applicable method" Error in r programming

This is caused by using an object-oriented ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 51,950 points
465 views
+1 vote
1 answer

“subscript out of bounds” Error in r programming

This error is likely to occur when ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 51,950 points
6,177 views
0 votes
2 answers

R Programming error in if condition

Hi. Instead of breaking the line add it ...READ MORE

answered Aug 26, 2019 in Data Analytics by anonymous
• 32,490 points
111 views
0 votes
1 answer

R programming: Unexpected symbol error

Format your code this way: myfunction <- function() ...READ MORE

answered Dec 17, 2018 in Data Analytics by Sophie may
• 10,100 points
1,212 views
0 votes
1 answer

R Programming error in 'fert'

You're using a factor: fert <- factor(c(50,20,10,10,20,50)) levels(fert) #[1] ...READ MORE

answered Dec 27, 2018 in Data Analytics by Sophie may
• 10,100 points
101 views
+1 vote
1 answer

R Programming: Market Basket Analysis Error

The basket.sorted() has less than 5 rules. Refer ...READ MORE

answered Feb 11, 2019 in Data Analytics by Sophie may
• 10,100 points
428 views
+1 vote
1 answer

R Programming: regexpr error

The below code will help: gregexpr("D", x) # [[1]] # ...READ MORE

answered Feb 21, 2019 in Data Analytics by Tyrion anex
• 8,550 points
69 views
+1 vote
1 answer

R programming error

Alright, you can either use gsub to match the ...READ MORE

answered Dec 18, 2018 in Data Analytics by Tyrion anex
• 8,550 points
72 views
0 votes
1 answer

R Programming error: twitteR OAuthFactory object

You need to install the following packages: install.packages(c('RO ...READ MORE

answered Jan 11, 2019 in Data Analytics by Tyrion anex
• 8,550 points
197 views