I was looking for an example of complex variables in R.  This one is trivial, 
but rather cute (though World War II aficionados may 'come over all funny').

See if you can guess the image before you try the function.  It's not difficult.

jif <- function(res = 100) {
  z <- sample(do.call(complex, subset(expand.grid(real =
                                                  seq(-3, 4, len = 7*res + 1), 
                                                  imaginary =
                                                  seq(-2, 2, len = 4*res + 1)),
                                      real > -2.439 & real < 3.717)))
  del <- 2*base::pi/32
  plot(z, type = "n", asp = 1, ann = FALSE, axes = FALSE)
  points(z[((Arg(z) + del/2) %/% del) %% 2 == 0
           | Mod(z) < 1.15], col = "red", pch = ".")
}

Njoi.

Bill Venables.
______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to