仪表板 - (表盘)米

时间:2012-09-22 15:46:30

标签: r dashboard

我想知道是否可以在R中使用这种仪表板(我的意思是这种情节)?

以下是我想在R中做的例子(首先来自SAS

编辑:我在Windows 7(64位)上工作。

enter image description here

enter image description here

3 个答案:

答案 0 :(得分:7)

这是从使用基本图形开始的。让它更漂亮留给读者。您可以在此处查看示例:http://www.math.csi.cuny.edu/gw/ex-dashboard.R

dashboard <- function(dial=list(
                        list(color="red",
                             range=c(10, 40)),
                        list(color="yellow",
                             range=c(40, 60)),
                        list(color="green",
                             range=c(70, 100))
                        ),
                      value=from) {


  from <- min(unlist(lapply(dial, "[[", i="range")))
  to <-  max(unlist(lapply(dial, "[[", i="range")))

  theta <- seq(-pi/3, pi + pi/3, length=100)
  r <- 1

  scale <- function(x) {
    m <- (pi + pi/3 - (-pi/3))/(from - to)
    (pi + pi/3) + m*(x - from)
  }

  plot.new()
  plot.window(xlim=c(-1, 1), ylim=c(sin(-pi/3), 1))

  lines(cos(theta), sin(theta))
  sapply(dial, function(l) {
    d <- scale(l$range)
    x <- seq(d[1], d[2], length=100)
    lines(cos(x), sin(x), col=l$color, lwd=3)
  })

  ticks <- pretty(c(from, to), n=5)
  ticks_th <- scale(ticks)
  r <- 1 - .15
  text(r*cos(ticks_th), r*sin(ticks_th), labels=ticks)

  sapply(ticks_th, function(th) {
    lines(cos(th)*c(1,.95), sin(th)*c(1, .95))
  })

  r <- 1 - .25
  th <- scale(value)
  arrows(0, 0, cos(th), sin(th))


}

dashboard( value=60)

答案 1 :(得分:5)

你可以用极坐标图做类似的事情:

require(plotrix)
polar.plot( c(0,20),c(0,60),main="Dashboard",lwd=3,line.col=4)

如果要自定义外观,可以深入挖掘代码。使用radial.plot可以为您提供更多自定义。

polar plot

答案 2 :(得分:2)

这与R几乎没有关系,只与如何获取表示仪表板项目的GUI小部件

我认为Gtk2可能会这样做,所以RGtk2包(及其包装器)可能会有所帮助。我知道Qwt工具包有一个事实,但是那个更难以访问(因为你需要一个C ++桥)。