R: package ggdendro plotting labels disppear - r

When I use the great package ggdendro to plot my tree, I come across a problem: One day, all labels of the tree it produces suddenly all disappeared.
When I run the following code in my local machine and in server, I get different results. No labels in local machine and labels do exist in the server version.
fit = ClustOfVar::hclustvar(X.quanti = mtcars)
ggdendro::ggdendrogram(as.dendrogram(fit),rotate = TRUE)
Server Version(OK):
Local Windows 7 Version(No labels):
I printed the session info as well for references.
dput compare(the same)
:

This issue has been fixed in the latest development version of ggdendro, version 0.1.19
The underlying issue is described at issue #24. This bug was exposed in a change of behaviour in ggplot2, and causes a problem with the scales package version 0.4. To be clear - the bug was in ggdendro, not ggplot2 or scales, but never surfaced when using earlier versions of scales.
This version is not yet on CRAN, so use devtools to get the latest version:
devtools::install_github("andrie/ggdendro")
Update. Version 0.1-20 of ggdendro is now available on CRAN.

Related

How to install/import MakieLayout

I'm trying to run this simple example, taken directly from the official documentation
using AbstractPlotting.MakieLayout
using AbstractPlotting
scene, layout = layoutscene(resolution = (1200, 900))
ax = layout[1, 1] = LAxis(scene, xlabel = "x label", ylabel = "y label",
title = "Title")
But I get an error at line 1: MakieLayout not defined
I have successfully installed Makie (v0.11.0) and AbstractPlotting (v0.11.2). I still managed to run the example by installing and importing MakieLayout as a separate package but MakieLayout as a package is deprecated and should have been absorbed by AbstractPlotting.
My questions are:
Am I doing something wrong here?
Is this an isolated issue or do other people have the same problem?
I would really appreciate some help if someone knows what is going on here.
AbstractPlotting's current version (Nov 5 2020) is 0.13.5. I recommend updating it before trying to use AbstractPlotting.MakieLayout.
You can update this package by doing
] update AbstractPlotting
If it is not correctly updated, it is possible that some other package is holding it back.
To discover what package is holding it back you can try to add the specific version by doing
] add AbstractPlotting#0.13.5
And you will get a more informative error message.
I advice you to remove the MakieLayout package before updating since this is obsolete and it is probably holding AbstractPlotting's version back.
EDIT (6 November 2020):
Nowadays it is not necessary to install the Makie.jl package. You can safely remove it and add instead:
AbstractPlotting
And one or more of the backends:
GLMakie (] add GLMakie), the fastest and more complete, uses GPU
CairoMakie (] add CairoMakie) if you don't have GPU or want to output to vector graphics
WGLMakie (] add WGLMakie)
the package called Makie is just AbstractPlotting + GLMakie and I think it is on its way out. You should remove the package and change your first line to:
using AbstractPlotting, GLMakie #or your selected backend
using AbstractPlotting.MakieLayout
Information about managing versions and packages can be found here

Can't plot step response in Octave

Iam trying to plot step response in Octave (v 4.0.3) using this code:
pkg load control
clf;
s = tf('s');
g = 1/(2*s^2+3*s+4);
step(g);
But I get always the same error:
error: matrix cannot be indexed with .
error: called from
plot at line 198 column 7
__time_response__ at line 207 column 13
step at line 74 column 10
If I used the same code in another computer with Octave 5.0.2 the code works perfectly, so I guess this is some kind of problem with this version.
I just want to know if there is some kind of workaround to plot my step response, cause this I need this particular version of Octave, so upgrade it is not a solution for my right now.
Thanks!
plot has likely changed quite a bit since that old version of Octave came out, and you didn't mention the package version, but I'm guessing you are probably trying to use a current version of control? The newest version would have been coded to accommodate any changes in Octave since then. Best bet might be to try to uninstall the control package (pkg uninstall control) and find an old version from around the same time as Octave 4.0.3.
According to the Octave Major Release History page, 4.0.3 came out on 2016-07-01. Looking at the Control Package News page, you probably want to try control-3.0.0, Release Date: 2015-10-30. (the next version was in 2018 right around Octave 4.2.2, and might also work. I didn't see a note about the plot or step function behavior changing, so you might have to try a couple versions to find one that works with plot from 4.0.3.)
The Octave Control Package page has a link to Older Versions which just takes you to the SourceForge file host. Navigating from there to Octave Forge Packages, individual package releases, will give you a chronological package download list where you can find different control packages to try. Scroll down or do a Find for 'control' and you should see 3.0.0 there.

Error: ScalesList was built with an incompatible version of ggproto

I'm doing a presentation in slidfy, using the deckjs framework.
Everything was ok, but suddenly this chunk of code:
ggplot(cars, aes(x = speed, y = dist)) + geom_point(color = 'red') + stat_smooth(method = "lm", formula = y ~ x, size = 0.5, se = F)
stopped working and shows this error instead:
## Error: ScalesList was built with an incompatible version of ggproto.
## Please reinstall the package that provides this extension.
The code works perfectly when executed from source or console... But it doesn't work anymore from the R markdown. The function that fails is the stat_smooth(). The rest visualizes ok if executed without the smooth.
Here and here a similar error is reported, and the solution offered is to reinstall ggplot and the packages from github, but I'm not sure which packages should I install, and, besides, the code only fails from Rmarkdown, and not when executed from console or source.
Thanks
I had a similar problem in RMarkdown after updating ggplot2. I was loading a workspace with plots created with the older version of ggplot2. The solution was to recreate that workspace with the updated version, and now RMarkdown works.
This is very strange; now things are back to normal.
I did what #baptiste suggested, and the R source code just worked ok.
After that, I knitted the Rmarkdown again and the error had disappeared!
in Feb 2017 the same error was resolved by re-installing all the packages (RStudio - Tools - Check for package updates)
I had similar problem with geom_tufteboxplot . I first updated ggplot2 & ggthemes package, then detached all ggplot related packages and reloaded them. It worked for me.

How to plot in RStudio and not have a new window pop up (R Graphics: Device (ACTIVE)?

Whenever I plot any plot in RStudio, I get a new device window that pops up. This was not always the case. I must have changed some settings. How do I change the settings back to have plots go to the RStudio plot window?
I have explored the dev.off() and other dev functions without success. For example:
# Clear workspace
rm(list=ls())
# create data
set.seed(1)
x <- rnorm(100, 0, 1)
y <- rnorm(100, 3, 1)
plot(x,y)
produces the popped up window in the screenshotted image:
I want the device to stay in the RStudio plot window in the lower righthand corner. Does anyone have any help? I saw a similar question here that claims that an update will fix the issue. I updated within the last week. When I use sessionInfo() I am running R version 3.3.2, what I believe to be the latest version of R.
I know that this has been answered but the problem can arise in multiple ways. My issue had been much simpler. The plots were not showing up in the Rstudio plot pane simply because the default null GD was turned off via dev.off(). I'm running Rstudio Version 1.1.442 with R Version R-3.4.4
I ran dev.off() a few times until all windows including hidden ones were closed and I received the following response in the console window.
null device
1
I then ran this and the plot appeared in the RStudio plot pane
dev.new()
plot(mtcars$mpg~mtcars$disp)
For others who like me may still encounter this issue:
This is probably caused by an R update to 3.3.2 and is fixed by installing a newer version of RStudio. In my case 1.0.136 did the trick.
I solved this problem by updating RStudio (Help--> check for updates). The new version of RStudio I updated to is Version 1.1.383 and this problem was fixed. Currently I have version 3.4.3 for R.
Go to R studio menu bar and Tools->Global options->R Mark down
In that phase select "window" from that list in the "show output preview in:" then apply

Unable to get plots displayed in Rstudio graphical viewer.

When I run my code all my graphs (both ggplot2 and plot) are displayed in an external "Quartz 2 [*]" graphical viewer.
I would like them to be displayed in the R studio GUI plot area to I can better save and view my files, along with the previous versions.
Is there anyway to stop this?
I recently updated my version of R, along with the X11 and xQuartz on my mac (also up to date), and I am guessing these updates are behind it.
I have seen many forums explaining how to get rstudio to export to an external viewer (e.g. "quartz()"), but not the other way.
I have looked, but these threads have not helped:
ggplot plots in scripts do not display in Rstudio
plot panel does not produce plots Rstudio
dev.off() even when hidden hide <- dev.off() is not working either.
Any help would be great,
Thanks.
If you upgrade R without upgrading RStudio, the graphics engine may not be compatible. To fix the "Quartz 2" popout, upgrade RStudio to a newer version that supports the graphics engine in the version of R you have installed.
I had the same problem, and noticed the following output to the console:
Warning message:
R graphics engine version 15 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.
Looks like I forgot to reinstall Rstudio as well.. That sorted my problem.

Resources