I have installed ggplot and ggplot2 and their dependencies, but I cannot use the function ggplot
; whenever I try to use it I get
Error in ggplot ... could not find function "ggplot"
It's saying when you try to load ggplot2, it can't because this dependency isn't installed yet. Some options: Just install the full tidyverse: http://tidyverse.tidyverse.org/#installation. This includes Rcpp.
This error usually occurs when a package has not been loaded into R via library . R does not know where to find the specified function. It's a good habit to use the library functions on all of the packages you will be using in the top R chunk in your R Markdown file, which is usually given the chunk name setup .
You'll notice that the qplot() function cannot be found. That's because while ggplot2 is installed (i.e., present in the library), it is not loaded (i.e., off the shelf). If you want to use a function from the ggplot2 package, you need to load the package using the library() function.
The ggplot2 package can be easily installed using the R function install. packages() . The above code will automatically download the ggplot2 package, from the CRAN (Comprehensive R Archive Network) repository, and install it.
Try:
library(ggplot2)
Even after installing a package, you have to load a package each time you load R.
This question is answered comprehensively in the r-faq:
Error: could not find function ... in R
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With