Rshiny 앱에서 R Diagram 라이브러리를 사용하여 만든 순서도를 표시하는 방법은 무엇입니까?

RanonKahn

Diagram아래 표시된 것과 유사한 RShiny 앱에서 R 라이브러리를 사용하여 순서도를 표시하려고 합니다. 시도 plotOutput()했지만 Rshiny 앱 탭에 순서도를 표시 할 수 없습니다. 누군가 내가 여기서 놓친 것에 대해 가르쳐 줄 수 있습니까?

library(diagram)
library(shape)

    par(mar = c(1, 1, 1, 1))
    openplotmat()
    elpos <- coordinates (c(1, 1, 2, 4))
    fromto <- matrix(ncol = 2, byrow = TRUE, data = c(1, 2, 2, 3, 2, 4, 4, 7, 4, 8,3,5,3,6))
    nr <- nrow(fromto)
    arrpos <- matrix(ncol = 2, nrow = nr)
    for (i in 1:nr)
      arrpos[i, ] <- straightarrow (to = elpos[fromto[i, 2], ],
                                      from = elpos[fromto[i, 1], ], lwd = 2, arr.pos = 0.6, arr.length = 0.5)
      textellipse(elpos[1,], 0.1, lab = "start", box.col = "green",
                  shadow.col = "darkgreen", shadow.size = 0.005, cex = 1.5)
      textrect (elpos[2,], 0.15, 0.05,lab = "found term?", box.col = "grey",
                  shadow.col = "darkblue", shadow.size = 0.005, cex = 1.5)
      textrect (elpos[4,], 0.15, 0.05,lab = "related?", box.col = "grey",
                  shadow.col = "darkblue", shadow.size = 0.005, cex = 1.5)
      textellipse(elpos[3,], 0.1, 0.1, lab = c("other","term"), box.col = "orange",
                    shadow.col = "red", shadow.size = 0.005, cex = 1.5)
      textellipse(elpos[7,], 0.1, 0.1, lab = c("make","a link"),box.col = "orange",
                    shadow.col = "red", shadow.size = 0.005, cex = 1.5)
      textellipse(elpos[8,], 0.1, 0.1, lab = c("new","article"),box.col = "orange",
                    shadow.col = "red", shadow.size = 0.005, cex = 1.5)
      textellipse(elpos[5,], 0.1, 0.1, lab = c("make","a link"),box.col = "orange",
                  shadow.col = "red", shadow.size = 0.005, cex = 1.5)
      textellipse(elpos[6,], 0.1, 0.1, lab = c("new","article"),box.col = "orange",
                  shadow.col = "red", shadow.size = 0.005, cex = 1.5)
    #
     dd <- c(0.0, 0.025)
      text(arrpos[2, 1] + 0.05, arrpos[2, 2], "yes")
      text(arrpos[3, 1] - 0.05, arrpos[3, 2], "no")
      text(arrpos[4, 1] + 0.05, arrpos[4, 2] + 0.05, "yes")
      text(arrpos[5, 1] - 0.05, arrpos[5, 2] + 0.05, "no")
    #
shaojl7

plotOutputUI와 renderPlot서버 에서도 사용 했습니까 ? 나는 다음을 시도했고 그것은 나를 위해 작동합니다.

#

# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
#    http://shiny.rstudio.com/
#

library(shiny)
library(diagram)
library(shape)

# Define UI for application that draws a histogram
ui <- fluidPage(
  # Show a plot of the generated distribution
  mainPanel(
    plotOutput("testplot")
  )
)

# Define server logic required to draw a histogram
server <- function(input, output) {
  #
  output$testplot <- renderPlot({
    par(mar = c(1, 1, 1, 1))
    openplotmat()
    elpos <- coordinates (c(1, 1, 2, 4))
    fromto <- matrix(ncol = 2, byrow = TRUE, data = c(1, 2, 2, 3, 2, 4, 4, 7, 4, 8,3,5,3,6))
    nr <- nrow(fromto)
    arrpos <- matrix(ncol = 2, nrow = nr)
    for (i in 1:nr)
      arrpos[i, ] <- straightarrow (to = elpos[fromto[i, 2], ],
                                    from = elpos[fromto[i, 1], ], lwd = 2, arr.pos = 0.6, arr.length = 0.5)
    textellipse(elpos[1,], 0.1, lab = "start", box.col = "green",
                shadow.col = "darkgreen", shadow.size = 0.005, cex = 1.5)
    textrect (elpos[2,], 0.15, 0.05,lab = "found term?", box.col = "grey",
              shadow.col = "darkblue", shadow.size = 0.005, cex = 1.5)
    textrect (elpos[4,], 0.15, 0.05,lab = "related?", box.col = "grey",
              shadow.col = "darkblue", shadow.size = 0.005, cex = 1.5)
    textellipse(elpos[3,], 0.1, 0.1, lab = c("other","term"), box.col = "orange",
                shadow.col = "red", shadow.size = 0.005, cex = 1.5)
    textellipse(elpos[7,], 0.1, 0.1, lab = c("make","a link"),box.col = "orange",
                shadow.col = "red", shadow.size = 0.005, cex = 1.5)
    textellipse(elpos[8,], 0.1, 0.1, lab = c("new","article"),box.col = "orange",
                shadow.col = "red", shadow.size = 0.005, cex = 1.5)
    textellipse(elpos[5,], 0.1, 0.1, lab = c("make","a link"),box.col = "orange",
                shadow.col = "red", shadow.size = 0.005, cex = 1.5)
    textellipse(elpos[6,], 0.1, 0.1, lab = c("new","article"),box.col = "orange",
                shadow.col = "red", shadow.size = 0.005, cex = 1.5)
    #
    dd <- c(0.0, 0.025)
    text(arrpos[2, 1] + 0.05, arrpos[2, 2], "yes")
    text(arrpos[3, 1] - 0.05, arrpos[3, 2], "no")
    text(arrpos[4, 1] + 0.05, arrpos[4, 2] + 0.05, "yes")
    text(arrpos[5, 1] - 0.05, arrpos[5, 2] + 0.05, "no")
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관