could not find function "ggplot"

Hi guys,
I am coding with R. My code worked untill yestarday.
Today I'm getting the following error:

Error in ggplot(data = working_data, aes(x = working_data$Column1,  : 
  could not find function "ggplot"

I have installed:


but nothing, it doesn't work.

I tried to remove packages, but, again, I'm getting 'ggplot2' not found.

I have done some updates, could it be this the reason?

Thank you so much for your help!

I think we need a little more information to help you, have you updated R itself since yesterday? What version of R are you using now? On which operating system are you? What is the output of running this command on the R console?


Thank you andresrcs,
R version 3-5-1
Windows 10 Pro
Output: [..] Desktop/R-3.5.1/library
Yep, in the last two days I run some updates in R
thank you for your help!

When you update R on windows the packages you have installed for the previous version are not available for the new one out of the box, you have to manually move them to the new location or point libpath to the old location.
Just to clarify are this the steps you have taken so far?

remove.packages("ggplot2") # Unisntall ggplot
install.packages("ggplot2") # Install it again
library(ggplot2) # Load the librarie (you have to do this one on each new session)

Do you know about sessions? For example, did you run library(ggplot2) earlier, close R Studio, then open it up again? Code run in a previous session won't be run when you start a new one.

This can be surprising, because R likes to push "workspace images" as a default behavior; when you exit a session, you may be asked, "Save workspace image?" This creates a file named .RData in the working directory which stores all the objects in your session's environment. Whenever you start a new session in that directory, it will automatically load them. But it won't reload packages.

If you haven't already, I'd suggest disabling this behavior and the pop-up window. In RStudio, go to Tools > Global Options > General. Then uncheck "Restore .RData into workspace at startup" and set "Save workspace to .RData on exit" to "Never."


The best practice is to write scripts that can recreate the work each time. This reduces the chance of unpleasant surprises from leftover objects in the workspace. If you do need to save data (e.g. it takes half an hour to create a dataset), use the save() and load() functions in your script. That way, anyone reading it (including future you) will know what's going on.

When I run
I get:
Error: package or namespace load failed for ‘ggplot2’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘colorspace’
In addition: Warning message:
package ‘ggplot2’ was built under R version 3.5.3

I don't know if this message could help us to understand.
Thank you again!

That error message is different, you have to install the missing dependency


Also, there is some discrepancy here, you said that you have R 3.5.1 but the message says that you have installed ggplot2 under R 3.5.3, could you clarify?

Hi nwerth,
I clicked "No" when "Save workspace image?" was asked to me.
Thank you

Thank you for your feedback

When I open R, there is written: R version 3.5.1 (2018-07-02) -- "Feather Spray" [...]. For this reason, I don't know why I get the error "package ‘ggplot2’ was built under R version 3.5.3". It is one of my doubts.

It seems to be the solution. Thank you!

If your question's been answered (even by you!), 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:

Could you help me to understand the problem with the R version?

That's not actually an issue (as far as I can see).

R packages issue warnings when the version of R they were built on are more recent than the one you have installed. The majority of the time this is not a problem, so hence it's only a warning. However, it is possible that some things will not work correctly if they rely on features from the more recent version of R.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.