Problem with Installing ggplot2

Hi

I was trying to install ggplot2 in Rstudio, the code was:

package ‘ggplot2’ successfully unpacked and MD5 sums checked

-I have downloade rTools from https://cran.r-project.org/bin/windows/Rtools/ to have less errors messages. However, it is still doesn't run through.

Please help!!!

Thanks

1 Like

Hi, and welcome!

I don't have a Windows box available to check, but that doesn't look like an error message to me, just informational.

In the console tab, what is the output of

library(ggplot2)

If it's just another > that means the library is installed.

Hi @Jessie123

Just because the text is in Red font does not mean that it is an error. The package has successfully installed itself in your system

You can double check this by typing library(ggplot2) as suggested by @technocrat and if you see no text/output then the installation is good to go

> install.packages("ggplot2")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/ggplot2_3.2.1.zip'
Content type 'application/zip' length 3976166 bytes (3.8 MB)
downloaded 3.8 MB

package ‘ggplot2’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\...

Warm Regards,
Pritish

The output of Code: library(ggplot2) is :>library(ggplot2)

So all is well?

library(ggplot2)

ggplot(mpg, aes(displ, hwy, colour = class)) + 
  geom_point()

Created on 2019-11-24 by the reprex package (v0.3.0)

Hi

I got the exactly the same graph after input the code you provided. Does it mean ggplot2 installed succesfully?

Beside, I want to ask why you didn't write code like x=displ, y= hwy. What is mpg? I know your code is a combination to create a graph with x,y and colored with geom_point() to add a layer.

Thank You

Jielan

Yup, everything is working!

I should have identified the snippet as from the documentation. mpg is a built-in dataset.

ggplot(mpg, aes(x= displ, y = hwy, colour = class)) + 
  geom_point()

works just as well as the positional arguments (displ, the x-axis comes first, hwy, the y-axis second). It's a matter of taste; I probably usually make it explicitly more often than not.

Looks like you've grasped the basic idea, which is building layers. Have fun!

1 Like

Hi Technocrat,

One more question followed, the code run out the graph at first time, after couple of hours, the graph dosen't run out again, but the code shows correct in console.

Do you have ways to solve the graph run out barriers? After I could control the graph, I will be able to add things by codes and see the changes in graph.

Jielan

This is a different question and is no longer about package installation, please ask it on a new topic providing a relevant REPRoducible EXample (reprex) for this new issue.

@andresrcs is suggesting a helpful practice--a new topic for when the question changes. In this case, as he points out, we've moved beyond installation into how to use the ggplot2 package, and people who have that question aren't likely to be looking under installation. So, please do post as a new question with a reproducible example, called a reprex .

On the other hand, while you're doing that, I'll take a guess about what may be happening.

library(ggplot2)

ggplot(mpg, aes(displ, hwy, colour = class)) + 
 geom_point()

opens a viewer window and displays the graphical result. If you close the window, you have to run the code again. That gets tedious, so you can create an object to be able to display the graph any time. (You can also save an image to file with ggsave().)

library(ggplot2)
p <- ggplot(mpg, aes(displ, hwy, colour = class)) + 
  geom_point()
p

Created on 2019-11-24 by the reprex package (v0.3.0)

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