2016-03-30 25 views
0

Çalışmaya başladığım için sorun yaşıyorum. İki kullanıcı girişini kabul etmek, ui.R'den server.R'ye geri göndermek ve bunu bir veritabanından dosyayı indirmek için bir URL sorgu dizesine bir değişken olarak eklemek istediğiniz bir Parlak uygulamasına sahibim. İlk önce, algoritmayı test etmek için değerleri kodladık, ancak sonunda kullanıcı tanımlı hale getirmek istiyoruz. Değişken olarak kaydetmeyi ve sorgu dizesinde değiştirmeyi düşünürdüm ama yapmadı ... URL'nin parçalarını birleştirmeye çalıştım ve bir hata alıyorum "Uyarı: Kedi hatası: argüman 1 ('closure' yazın 'kedi' tarafından ele alınamaz. İnternette arama yapmayı denedim, ancak sorunuma iyi bir çözüm bulamadı. İşte benim kodum şu ana kadar ... Kodda gördüğünüz gibi, en azından url'yi oluşturmak ve onu dinamik olarak görmek için ui üzerinde metin olarak göstermek istiyorum. Sonra, kullanıcı girdisini ekleyebileceğimi bildiğim zaman, indirilen dosyayı saklamak için devam edebilirim. Eğer Ayrıca muhtemelen URL almak yerine paste arasında paste0 kullanmalıdırParlak bir şekilde bir URL sorgu dizesine kullanıcı girdisini geçirme

output$text <- renderText({ 
    textInput() 
}) 

kullanmalıdır böylece

#ui.R 

library(shiny) 
library(leaflet) 
library(foreach) 
library(ape) 
library(data.table) 
library(DT) 

# Choices for the genetic distance model 
geneticDistanceModel <- c(
    "raw" = "raw", 
    "JC69" = "JC69", 
    "K80" = "K80", 
    "F81" = "F81", 
    "K81" = "K81", 
    "F84" = "F84", 
    "BH87" = "BH87", 
    "T92" = "T92", 
    "TN93" = "TN93", 
    "GG95" = "GG95", 
    "logdet" = "logdet", 
    "paralin" = "paralin" 
) 

shinyUI(navbarPage("TeMPuЯa", id="nav", position = c("fixed-top"), 
    # needed to keep fixed-top navbar from obscuring content 
    header = tags$style(type = "text/css", "body {padding-top: 70px;}"), 
    collapsible = "true", 
    tabPanel("Tool", 
    h1("Instructions"), 
    p("Placeholder"), 
    sidebarLayout(
     sidebarPanel(
     textInput("taxonomy", label = h4("Enter taxonomy group:"), value = "Porifera"), 
     textInput("geography", label = h4("Enter geographical location:"), value = "all"), 
     sliderInput("latitude", label = h4("Latitude difference"), min = 10, max = 30, value = 20), 
     sliderInput("genetic", label = h4("Genetic similarity threshold"), min = 10, max = 20, value = 15), 
     sliderInput("outgroups", label = h4("Select a distance from the outgroup"), min = 1, max = 2, value = 1.3, step = 0.1), 
     selectInput("distanceModels", label = h4("Select a genetic distance model"), geneticDistanceModel, selected = "K80"), 
     submitButton("Submit"), 
     br(), 
     downloadButton("download", label = "Download CSV") 
    ), 
     mainPanel(
     leafletOutput("worldmap"), 
     br(), 
     div(style='height:300px; width:850px; overflow:scroll', 
      DT::dataTableOutput("url", width = 850)), 
     textOutput("text") 
    ) 
    ) 
), 
    tabPanel("Genetic Distance Models Info", 
    h1("Genetic distance models:"), 
    a("Link to more explanation for the distance models used in R", href = "http://svitsrv25.epfl.ch/R-doc/library/ape/html/dist.dna.html"), 
    br(), 
    p(strong("raw:") ,"This is simply the proportion or the number of sites that differ between each pair of sequences. This may be useful to draw 'saturation plots'."), 
    p(strong("JC69:") ,"This model was developed by Jukes and Cantor (1969)."), 
    p(strong("K80:") ,"The distance derived by Kimura (1980), sometimes referred to as 'Kimura's 2-parameters distance'."), 
    p(strong("F81:") ,"Felsenstein (1981) generalized the Jukes-Cantor model."), 
    p(strong("K81:") ,"This model is called the Kimura's 'three substitution types model' (3ST), and is sometimes referred to as 'Kimura's 3-parameters distance'."), 
    p(strong("F84:") ,"This model generalized K80, and was first introduced by Felsenstein in 1984."), 
    p(strong("BH87:") ,"Barry and Hartigan (1987)."), 
    p(strong("T92:") ,"Tamura (1992) generalized the Kimura model."), 
    p(strong("TN93:") ,"Tamura and Nei (1993) model."), 
    p(strong("GG95:") ,"Galtier and Gouy (1995) model."), 
    p(strong("logdet:") ,"The Log-Det distance, developed by Lockhart et al. (1994), is related to BH87. However, this distance is symmetric."), 
    p(strong("paralin:") ,"Lake (1994) developed the paralinear distance which can be viewed as another variant of the Barry-Hartigan distance.") 
) 
)) 

# server.R 

library(shiny) 
library(leaflet) 
library(foreach) 
library(ape) 
library(data.table) 
library(DT) 
source("tsvtoDataFrame.R") 

shinyServer(function(input, output, session) { 
# Create the map 
    output$worldmap <- renderLeaflet({ 
    leaflet() %>% 
     addTiles() %>% # Add default OpenStreetMap map tiles 
     setView(lng = -93.85, lat = 37.45, zoom = 4) 
    }) 
textInput <- reactive({ 
    var1 <- "http://www.boldsystems.org/index.php/API_Public/combined?taxon=" 
    var2 <- "&geo=" 
    var3 <- "&format=tsv" 
    paste(c(var1), c(input$taxonomy), c(var2), c(input$geography), c(var3)) 

    }) 

    output$text <- renderText({ 
    textInput 
    }) 
output$url <- DT::renderDataTable( 
    dfMatchOverallBest, 
    options = list(scrollX = TRUE) 
) 


}) 

cevap

0

textInput, reaktif ve c() komut gerekli değildir.

+0

Ah ... Teşekkürler :) şimdi bir sonraki adıma geçebilirim. – wly5

+0

Lütfen cevabı kabul edildi olarak işaretleyin. –

İlgili konular