New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotVariance fails if it's the first plot in the script. #24

Closed
zeehio opened this Issue Apr 29, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@zeehio
Copy link

zeehio commented Apr 29, 2016

First of all thanks for your work on this package. It looks great.

In my computer the following script fails (with current CRAN 0.7.0 version and current master version):

library("mdatools")
data("people")
model <- pca(people)
plotVariance(model)

With error:

Error in strwidth(legend, units = "user", cex = cex, font = text.font) : 
  plot.new has not been called yet

Traceback:

7 strwidth(legend, units = "user", cex = cex, font = text.font) 
6 legend(position, legend, col = col, pch = pch, lty = lty, lwd = lwd, 
    plot = plot, cex = 0.8, inset = inset, bg = "white", box.lwd = 0.75, 
    box.col = "gray", ncol = ncol) at mdaplots.R#453
5 mdaplot.showLegend(legend, position = legend.position, plot = F) at mdaplots.R#185
4 mdaplot.getAxesLim(data, show.lines = show.lines, single.x = single.x, 
    show.legend = show.legend, legend = legend, show.labels = show.labels, 
    legend.position = legend.position, xticks = xticks, yticks = yticks) at mdaplots.R#1155
3 mdaplotg(data, main = main, xlab = xlab, ylab = ylab, labels = labels, 
    legend = legend, type = type, show.labels = show.labels, 
    ...) at pca.R#641
2 plotVariance.pca(model) at defaults.R#526
1 plotVariance(model) 

Session info:

sessionInfo()
R version 3.2.5 (2016-04-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.2 LTS

locale:
 [1] LC_CTYPE=ca_ES.UTF-8       LC_NUMERIC=C               LC_TIME=ca_ES.UTF-8        LC_COLLATE=ca_ES.UTF-8     LC_MONETARY=ca_ES.UTF-8   
 [6] LC_MESSAGES=ca_ES.UTF-8    LC_PAPER=ca_ES.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=ca_ES.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] mdatools_0.7.0

loaded via a namespace (and not attached):
[1] tools_3.2.5

As a workaround this works:

library("mdatools")
data("people")
model <- pca(people)
plot.new() # conventionally I don't need to use this
plotVariance(model)
@svkucheryavski

This comment has been minimized.

Copy link
Owner

svkucheryavski commented May 2, 2016

Hi Sergio,

thanks a lot for you kind feedback and the issues. My students told me once about this problem with plot.new() however I did not have time so far to look at it and fix it. Now it is done, plus the other suggestions (Roxygen and wrong case in data file) as well as some other minor improvements in the code. I decided that it will be simpler for me to do these fixes locally but thanks for the pull request as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment