0
Q:

r loops

# Basic syntax of for loop:
for (i in sequence) {
  code to be repeated
}

# Example usage of for loop:
for (i in 1:5) {
  print(i)
}


# Basic syntax of while loop:
while (condition_is_true) {
  code to be repeated
}

# Example usage of while loop:
i = 1
while (i < 5) {	# True while i is less than 5
  print(i)
  i = i + 1		# Increment i each iteration
}
1

New to Communities?

Join the community