0

New R-programming user. When I tried using ggplot on my R-studio, it appeared as ggplot2:: and I get Error: unexpected end of line in "ggplot2::" response

I want to use ggplot for data visualisation. Why is my function showing as ggplot2:: instead of ggplot.Is there something wrong with my installation.

MrFlick
  • 195,160
  • 17
  • 277
  • 295
Abi001
  • 1
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. What exactly does your code look like? It sounds like you have a syntax error but it's hard to say without being able to see the code. – MrFlick Aug 07 '23 at 19:18
  • 4
    Most new users shouldn't need to work with `::`-notation, not sure why you're using it. I would expect the tutorial or lesson plan to have you first eval `library(ggplot2)`, after which all functions made available with `ggplot2::` would be in your "search path" of available functions. FYI, `::` is just a "namespace accessor", you might read https://colinfay.me/intro-to-r/packages.html section 13.3 Namespaces for a brief description. If you're new to programming and that doesn't make sense, revert to my first sentence: most new users won't need this. Good luck! – r2evans Aug 07 '23 at 19:23
  • 2
    `ggplot2` is a package with functions, most importantly `ggplot()`, which is how we start most plots. Sometimes you might have functions from different packages with the same names. To overcome this ambiguity in R, we can type `ggplot2::ggplot()` to specify that we want the `ggplot()` function from the `ggplot2` package, and not any other `ggplot()` function from another package. This is usually not necessary. I suspect you might have added the `::` using autocomplete or something inadvertent. When I run `ggplot2::`, I get that error. – Jon Spring Aug 07 '23 at 20:36

0 Answers0