I'm trying to learn a bit of basic R - part of an attempt to get my head round Bayesian statistics. I'm working my way through 'Learn R in a Day by Steve Murray', experimenting with the examples in the book using the Console in RStudio Cloud, running within Chrome on my Chromebook. All is going pretty well, but try as I might I can't get any of the 'create a function' examples to work. Here's my problem:
I've two problems. First, I don't seem able to format the multiplier problem with the indents - except by repeatedly pressing the space bar. Second, I keep getting this error message telling me I'm getting an unexpected symbol. I've tried repeating this example using RStudio on my Windows 10 PC and using R on my Windows 10 PC, but always with the same error message. All this suggests I'd doing something very basic wrong.
Your problem is only a lack of line breaks.
The document on the left indicates the console is outputting a new line by showing you a plus symbol to symbolise that. Put the print statement onto a new line and not as a run on to the result assignment.
(Alternatively you could use a semi colon to have the effect of a new line without the newline, but that may be a poor habit to form)