problems with geom_bar plots

72 views
Skip to first unread message

Aref Nammari

unread,
Jun 7, 2020, 3:57:35 PM6/7/20
to ggplot2

Hello All,
I have installed R (version 4.0) as well as ggplot2 (version 3.3.1) and the tidyverse packge. I was going through some code from the book "R for Data Science". I was working with the diamonds dataset when I encountered the problem. I tried the following code:


library
(ggplot2) ggplot(data=diamonds) + geom_bar(mapping=aes(cut))
 

which produced the expected bar graph. Then I tried:


ggplot(data=diamonds) +
geom_bar(mapping=aes(cut, color = cut))

This did not produce anything and caused R to hang -- I had to kill R to exit. This happened regardless of whether I was in RStudio or using R from the terminal. The curious thing is that both of the above codes work just fine with the mpg dataset. My machine is Lenovo IdeaPad Flex running Ubuntu linux 20.04 LTS with 16GB of RAM and the processor is Intel i7 8th gen with GPU so resources should not be an issue for handling the large diamonds dataset--which is not really that large but certainly larger than the mpg dataset. The exact same thing was happening with R version 3.6.3 which I replaced with version 4.0.


Continuing to debug and trying to understand what is going on I plotted a histogram of the variable carat dataset . After this the geom_bar worked as expected but unfortunately reverts to not working properly when R is restarted.


Any help in understanding and eventually resolving this issue is greatly appreciated.



Cheers,
Aref

Manuel Gutierrez

unread,
Jun 7, 2020, 4:57:03 PM6/7/20
to Aref Nammari, ggplot2
I am fairly new to R too, but I think you may have to reinstall R again.

R is very fickle. I use it both in my Mac and a laptop with Ubuntu. Somethings work in one machine but not the other.

Manuel

From: ggp...@googlegroups.com <ggp...@googlegroups.com> on behalf of Aref Nammari <arefn...@gmail.com>
Sent: Sunday, June 7, 2020 2:56:54 PM
To: ggplot2 <ggp...@googlegroups.com>
Subject: problems with geom_bar plots
 
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ggplot2/12074d85-1c42-4258-aef3-f3097cf2a973o%40googlegroups.com.

Aref Nammari

unread,
Jun 7, 2020, 5:03:52 PM6/7/20
to ggplot2
Thank you. I have already reinstalled although I have to admit I have not completely uninstalled and then reinstall. I will try this and hopefully that will take care of things.
Cheers
To unsubscribe: email ggp...@googlegroups.com

More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggp...@googlegroups.com.

Aref Nammari

unread,
Jun 7, 2020, 5:44:36 PM6/7/20
to ggplot2
UPDATE: Completely uninstall ed R and removed all libraries. Reinstalled R and the tidyverse package and ggplot2. The same behavior with geom_bar persists.

Aref Nammari

unread,
Jun 8, 2020, 7:41:32 AM6/8/20
to ggplot2

This is not a solution but a workaround. I downloaded the diamonds.csv file and used it to do the plotting. All is good and works with no problems. I think the issue is either in how the dataset is stored or fetched from the ggplot2 library . The flights dataset from the library nycflights13 is quite a bit larger dataset than the diamonds dataset and it works fine. I am not going to worry about it for the time being. The issue could be related to settings or configuration specific to the installation on my machine. However, the options in Rstudio settings are not helpful and I can't seem to find any information regarding settings and configuration for R or Rstudio. Thanks for those who took the time to try to help me resolve this issue. Much appreciated.

Cheers



On Sunday, June 7, 2020 at 1:57:35 PM UTC-6, Aref Nammari wrote:
Reply all
Reply to author
Forward
0 new messages