Messy Code When Drawing Graph by R on linux - r

I am trying to draw graph by R on linux,
when I run this code: plot(1,1)
a graph with messy code is drawn
I am using OS linux, R 3.4.1 , jupyter notebook
Cairo is used as device for drawing.
I have tried these methods:
trying another method in R
trying another font
trying utf-8 encode
but these are not work.
It should not be problem of jupyter notebook because I run R console and draw the graph, the same problem happened. It should be problems in R, or Cairo, or something between them.

I have solved it by reinstalling R.

I had this same problem on a Linux machine where I used a conda installed R system running in Jupyter Notebooks. The issue for me turned out to be missing fonts. I solved it by using conda to install fonts:
conda install -c anaconda fonts-anaconda

Related

MAC OS Big Sur Python Works In Anaconda Navigator But R Doesn't

As is indicated by the photos here, Pythons works just fine in my Jupyter Notebook, I can pip install, use packages and everything, but R doesn't. I used Anaconda to access the Jupyter notebook. How can I get R working just like Python does. Thanks

Include dygraphs for R in Jupyter

I have an R notebook that I am trying to make into a Jupyter notebook using IRkernel, which I downloaded via Anaconda.
Everything works fine except when I try to use dygraphs, which just won't display the graph.
The only thing close to an answer I could find online is: https://doc.dataiku.com/dss/latest/R/dygraphs.html but I am not able to download the dataiku library for some reason.
I tried using conda install -c r r-dygraphs but it has made no difference.
On the dygraphs website they don't mention anything about using it in a Jupyter notebook so I'm not sure what to do. If it isn't supported on Jupyter, can someone point me to a close alternative to dygraphs that will work on Jupyter? The time series visualisation is really great on it which is why I want to implement it in my Jupyter notebook.
Thanks in advance!
If your error is something like:
ERROR while rich displaying an object: Error in file(file, "rb"): invalid 'description' argument
Then I think it's referring to not being able to plot the dygraphs in Jupyter. I would suggest checking out the "using" section on the documentation for R dygraphs. Although it doesn't strictly mention using dygraphs in Jupyter notebooks, it gives pointers for using them in R Console, R Markdown, and R Shiny. Lately I've been using them in an R shiny application and they've worked flawlessly, just as long as you set them up correctly. Also, just use:
install.packages('dygraphs')
in Jupyter notebooks to ensure successful installation and use. I've noticed that there are inconsistencies when running conda install commands (i.e. whether or not the package will end up working in Jupyter notebooks, RStudio, or both).
I think the problem is not in the install dygraphs, but it depends on jupyter notebook, this one can't appear dynamic graphic such as in RMarkdown.

ggplot function not found in jupyter notebook with rpy2

I am working on a computer cluster and testing out how to use a Jupyter notebook on it. I encountered this problem while trying to use ggplot2. I've tried installing the package in the notebook, with R in the command line, and with conda install, and r-ggplot2 (version 2.2.1) shows up in conda packages. Any ideas?
Judged by your screenshot, you are running a python-based notebook. It looks as if you are trying to use ggplot as part of the python package rpy2.
Based on this source, ggplot is present in rpy2.robjects.lib.ggplot2, so you might want to try something like
from rpy2.robjects.lib.ggplot2 import ggplot
...
ggplot(data=df)

remove anaconda R from Ubuntu

I have been using ipython notebook to run some R scripts. Now the problem is I have two R versions on my Ubuntu 14.04.
One is R.3.2.2 at /home/MYNAME/anaconda2/bin/R, another one is the R which I need for R studio,
now the problem is I want to only use R.3.3.1 for my system as I need some advanced task to be done.
I use conda uninstall r, after running this, according to the print out, a lot of R related packages is removed, if i run conda uninstall r again, it said
Fetching package metadata .......
Using Anaconda Cloud api site https://api.anaconda.org
Solving package specifications: ..........
Error: no packages found to remove from environment: /home/MyName/anaconda2
but when I run Which R again, still it is the anaconda R, if I run R in the terminal, it is still R3.2.2, anyone knows how could I remove this anaconda R version?
You probably needed to run hash -r in your session (or rehash if using zsh) to update your executables on PATH for the which command. A new terminal session would also fix the problem.
you can try conda uninstall r-base, this will remove R and all of the R-library.
The questions also implies that one cannot use anaconda R with rstudio.
On Linux you can
export RSTUDIO_WHICH_R=/home/USER/anaconda3/bin/R
and add to .profile (d/o your distro) to use rstudio with anaconda R and packages

R version doesn't support quartz graphic device - RStudio won't plot

I'm running Mac OS Maverick.
In my previous setup, the plots would correctly display on the plot tab on RStudio.
I reinstalled R with homebrew and, when I use RStudio, it gives me the following warning
WARNING: The version of R you are running against does not support the
quartz graphics device (which is required by RStudio for graphics).
The Plots tab will be disabled until a version of R that supports
quartz is installed.
When I plot something, it opens up the XQuartz app on my mac. It does display the graphs (sometimes with weird colors though), but I'd really like it to plot in RStudio itself.
Is it that homebrew has a version of R that doesn't support the quartz graphics device or have I messed up something elsewhere?
As always, any help will be very much appreciated.
Some details of my setup:
R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
RStudio Version 0.98.1091
Platform: x86_64-apple-darwin13.4.0 (64-bit). Mac OS 10.9.5
I installed R with homebrew the following way
brew tap homebrew/science
brew install r
Previously I had installed tcl/tk the following way
brew tap homebrew/dupes
brew install tcl-tk --with-tk
I run into the same issue.
According to the R brew formula history the last bottled version (i.e. precompiled version, which is what is installed by default) isn't run against aqua due to some bug so the installation of R has no aqua capabilities, which is what RStudio graphics device requires.
After trying to understand the formula logic I figured that if built from source:
brew install r --build-from-source
it would compile with clang (check brew --env) and therefore correctly build against aqua. It takes a little longer to install but it worked for me. To check, from the terminal open R and see capabilities() aqua should be TRUE for RStudio's graphics device to work.
I'm using homebrewed R and Rstudio on Yosemite. I ran into the same problem, probably after I had updated R from ver. 3.1.2 to ver. 3.1.2_1.
My ad-hoc solution is
to brew uninstall R, and
to install R from CRAN.
RStudio display graphs inside its window when I use CRAN version of R. However, this is not the best solution to me, because I love to manage all unix packages using homebrew to avoid possible conflicts.
I ran into this problem too. I previously had homebrewed R installation with a working quartz graphic device, which comports with others in this thread who suggest that an update to homebrew's R script caused the problem.
I can confirm that daniel's answer works. I tried brew install r --build-from-source and quartz() has stopped throwing errors.

Resources