Problem with use of one pair of brackets - as part of the Control Structures

Welcome to the forum.

It may be that you are typing in the console rather than the script window.

My version of RStudio looks like this:

You should be typing in the top left window in my layout and then submitting the code and the results should show up below.

Otherwise we need a reproducible example (reprex). See