2.1 Creating objects

You can get output from R simply by typing in math in the console

3 + 5
12/7
2*4
2^4

We can also comment what it is we’re doing

# I am adding 3 and 5. R is fun!
3 + 5

What happens if we do that same command without the # sign in the front?

I am adding 3 and 5. R is fun!
3 + 5

Now R is trying to run that sentence as a command, and it doesn’t work. Now we’re stuck over in the console. The + sign means that it’s still waiting for input, so we can’t type in a new command. To get out of this type Esc. This will work whenever you’re stuck with that + sign.

It’s great that R is a glorified caluculator, but obviously we want to do more interesting things.

To do useful and interesting things, we need to assign values to objects. To create objects, we need to give it a name followed by the assignment operator <- and the value we want to give it.