R语言包_manipulate

2019-05-26 21:42:20 浏览数 (1)

可以制作动态交互图标,比shiny简单一些。

代码语言:javascript复制
#Basic Usage
library(manipulate)
manipulate(plot(1:x), x = slider(1, 100))

#Slider Control
manipulate(
  plot(cars, xlim=c(0,x.max)),  
  x.max=slider(15,25))

#Picker Control
manipulate(
  barplot(as.matrix(longley[,factor]), 
          beside = TRUE, main = factor),
  factor = picker("GNP", "Unemployed", "Employed"))

#Checkbox Control
manipulate(
  boxplot(Freq ~ Class, data = Titanic, outline = outline),
  outline = checkbox(FALSE, "Show outliers"))

#Combining Controls
manipulate(
  plot(cars, xlim = c(0, x.max), type = type, ann = label),
  x.max = slider(10, 25, step=5, initial = 25),
  type = picker("Points" = "p", "Line" = "l", "Step" = "s"),
  label = checkbox(TRUE, "Draw Labels"))

参考资料

  1. RStudio Support

0 人点赞