ランダムに生成されたdata.frameがあります。スライダを変更してポイント数を選択することができます。それから私はこのdata.frameをプロットします。R Shiny:data.frameを更新するボタンを作成します。
クリックしたときよりもボタンを追加したいのですが、以前にランダムに生成されたdata.frame(ただしdata.frameを再生成しません)で変更を行います。変更はボロノイド緩和であり、ボタンがクリックされグラフが生成されるたびに1回実行する必要があります。
今まで、私は似た何かを達成していない...もちろん
ui.R
library(shiny)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
# Application title
titlePanel("Map Generator:"),
# Sidebar with a slider input for the number of bins
sidebarLayout(
sidebarPanel(
p("Select the power p to generate 2^p points."),
sliderInput("NumPoints",
"Number of points:",
min = 1,
max = 10,
value = 9),
actionButton("GenPoints", "Generate"),
actionButton("LloydAlg", "Relaxe")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot",height = 700, width = "auto")
)
)
))
server.R
library(shiny)
library(deldir)
shinyServer(function(input, output) {
observeEvent(input$NumPoints,{
x = data.frame(X = runif(2^input$NumPoints,1,1E6),
Y = runif(2^input$NumPoints,1,1E6))
observeEvent(input$LloydAlg, {
x = tile.centroids(tile.list(deldir(x)))
})
output$distPlot <- renderPlot({
plot(x,pch = 20,asp=1,xlim=c(0,1E6),ylim = c(0,1E6))
})
})
})
私がやってしなければならないものがあります間違っていますが、私はまったく新しいものです。私が間違っていることを理解できません...