New to R - Keep seeing "Error: object 'a' not found"

Please, I installed the RStudio Version 1.2.1335 and R version 3.6.1on my MacBook Pro.
However, I keep receiving the "Error: object 'a' not found" despite defining the object.
I type "a", then "print(a)" also but its the same outcome.
I try doing other things like finding log(8) and 2^3 and it returned the values without an error message.
I downloaded the library (dslabs) and I called it at the beginning, not sure if that is necessary though.
Also when I type in ls() to see the object saved in the workspace, it returns

> ls()

I am not sure what I did wrong

I need help.

How exactly are you defining a? Try this simple code:

a <- 5
b <- a*2
#> [1] "a" "b"

Created on 2019-09-18 by the reprex package (v0.2.1)

Hi, Thanks

I typed in:
a <- 1

i have tried the code suggested.
i still get an error message and the ls() returned Character(0).

Are you doing all of your typing in the Console, the lower left panel in RStudio? If so, I can't imagine what is going on.

1 Like

I just figured out i was typing in wrong place.
I was typing in the upper left panel in RStudio and expected the result to be in the console.
It's working fine now.

Thanks for your help

You've probably figured this out by now, but typing in the upper left (the script pane, by default), is actually a good idea once you get going! :grinning: You can use Cmd-Enter (or the little green Run button) to automatically send your current line or selection to the Console to be executed.

For a lot more about why writing all your code in script files is a good idea, see here:

Oh! Great!
Thanks for giving me more information about that. I’ve actually been wondering what the upper left space is useful for :blush:.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.