pearselab / r-intro-jocelyn-cuthbert

r-intro-jocelyn-cuthbert created by GitHub Classroom
0 stars 0 forks source link

#4 function struggles #3

Closed jocelyn-cuthbert closed 7 years ago

jocelyn-cuthbert commented 7 years ago

So I created a function and put in the extra bracket so that the argument (num in 1:20) would apply to all of the options, and not just the divisable by zero. I can get the function to work for a single number, but when I run the whole code, divisible by 5, prime, and break, I get:

Error: unexpected 'else' in: " is_prime3(num)
} else"

break

Error: no loop for break/next, jumping to top level } Error: unexpected '}' in " }" } Error: unexpected '}' in "}"

jocelyn-cuthbert commented 7 years ago

Nevermind I took out the Break and it worked....

willpearse commented 7 years ago

Glad it worked! You're doing very well - keep going!!!

Remember that sometimes an error a few lines earlier can mess up R, so check a few lines ahead of whatever R complains about. You did that in this case, so well done!