I have probably a rather simple question but R produces constantly errors if I try to assign a variable.
Example:
x <- c(1, 2, 3)
mean(x)
If I run this code in a R script the console reports the following error message:
Error in mean(x) : object 'x' not found
If I run the same code in the console everything works. I don't know why this happens right now, it worked in the past.
Hi, and welcome to community.rstudio.com !
Just to troubleshoot - since you're working with a script, have you made sure to actually run the line x <- c(1, 2, 3)
before running mean(x)
?
3 Likes
Oh, you are right.
I was working until now only in the DataCamp environment.
Thanks for the reply - Just started with R
If your question's been answered, would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:
If your question has been answered, don't forget to mark the solution!
How do I mark a solution?
Find the reply you want to mark as the solution and look for the row of small gray icons at the bottom of that reply. Click the one that looks like a box with a checkmark in it:
[image]
Hovering over the mark solution button shows the label, "Select if this reply solves the problem". If you don't see the mark solution button, try clicking the three dots button ( ••• ) to expand the full set of options.
When a solution is chosen, the icon turns green and the hover label changes to: "Unselect if this reply no longer solves the problem". Success!
[solution_reply_author]
…
Sure, will do.
Thanks a lot!
Chris