File: tile.r

package info (click to toggle)
r-cran-ggvis 0.4.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,716 kB
  • sloc: sh: 25; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 416 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
library(ggvis)

pp <- function (n, r = 4) {
  width <- 2 * r * pi / (n - 1)

  mid <- seq(-r * pi, r * pi, len = n)
  df <- expand.grid(x = mid, y = mid)
  df$r <- sqrt(df$x^2 + df$y^2)
  df$z <- cos(df$r^2)*exp(-df$r/6)

  df$y2 <- df$y + width
  df$x2 <- df$x + width
  df$x <- df$x - width
  df$y <- df$y - width
  df
}

pp(100) %>% ggvis(~x, ~y, x2 = ~x2, y2 = ~y2, fill = ~ z, stroke := NA) %>%
  layer_rects()