[R] Wireframe plot inside a function

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Fri Apr 21 18:27:10 CEST 2017


FAQ 7.22
And don't send HTML email... you are the one making it difficult for us to read your question. 

-- 
Sent from my phone. Please excuse my brevity.

On April 21, 2017 8:27:20 AM PDT, George Trojan - NOAA Federal <george.trojan at noaa.gov> wrote:
>Consider the following example:
>
>library("kdecopula")
>library("mvtnorm")
>
>pobs <- function(x) rank(x) / (length(x) + 1)
>
>n <- 1000
>
>sigma1 <- diag(x = 1, 2, 2)
>x1 <- rmvnorm(n, sigma = sigma1)
>xx1 <- apply(x1, 2, pobs)
>cop1 <- kdecop(xx1)
>
>eps <- 0.8
>sigma2 <- matrix(c(1, eps, eps, 1), ncol = 2)
>x2 <- rmvnorm(n, sigma = sigma2)
>xx2 <- apply(x2, 2, pobs)
>cop2 <- kdecop(xx2)
>
>x11()
>plot(cop1, main = "cop1 main")
>x11()
>plot(cop2, main = "cop2 main")
>
>cplot <- function(cop1, cop2) {
>  x11()
>  plot(cop1, main = "cop1 function")
>  x11()
>  plot(cop2, main = "cop2 function")
>}
>
>cplot(cop1, cop2)
>
>cat("Press <Enter> to quit")
>readLines(file("stdin"), n
>​ ​
>=
>​ ​
>1)
>quit()
>
>When I run it with Rscript all four x11 windows pop up, however the one
>that should display "cop1 function" is blank, the wireframe is not
>plotted.
>This is R 3.3.1, on Fedora 20.
>I see similar behaviour on Fedora 24, R 3.3.3 when I run the code from
>RStudio (the most recent one).
>
>George
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list