2015-04-05 55 views
-1

我正在嘗試編寫用戶在擲骰子中獲取的結果以及他點擊CSV文件中的投擲按鈕的時間,以便我以後可以在自己的時間訪問該文件。被動地將2個元素寫入csv文件

我從以下示例中借用了代碼(R/Shiny - How to write a .csv reactively including a actionButton?),但我無法合併多個被動行爲。因爲在可以得到的代碼將結果寫入一個csv文件,但是當我調用函數來獲取開始時間我得到以下錯誤 - 「收聽http://127.0.0.1:6949 錯誤.getReactiveEnvironment()$ currentContext(): 操作不允許沒有反應活性環境。(你試圖做一些事情,只能從做了反應表達或觀察者內。)」

rm(list = ls()) 
library(shiny) 
a<-sample(c(1:6),1,replace=TRUE) 

ui = pageWithSidebar(
    headerPanel('Min. working example - write a csv based on user input'), 
    sidebarPanel(

    p("Include actionButton to prevent write occuring before user finalises selection"), 
    actionButton("generateButton","throw")),mainPanel(tableOutput("test1")) 
) 

server=(function(input, output) { 

    getstart<-function(){ 

    if (input$runButton == 0) {return()} 
    else{ 
     v1<-Sys.time() 
     g1<-as.character(v1) 
    } 
    return(g1) 

    } 

    time<-getstart() 
    b<-as.character(time) 

    geodatasetInput <- observe({ 

    # Execute selections on data upon button-press 
    if(input$generateButton == 0) {return()} 
    else{ 

    AggSubGdata <- df 
    write.csv(AggSubGdata 
       , file = "solution21.csv" 
       , row.names=F 
    ) 
    } 
    }) 
    output$test1<-renderText({ 
    if(input$generateButton==0){return(NULL)} 
    else{ 
    a 
    } 
    }) 
}) 

runApp(list(ui = ui, server = server)) 

我試圖把getstart()函數閃亮的身體之外,觸發以用全局變量觸發它。我嘗試通過使用操作符< < - 運算符來將該值賦予此全局變量,但該嘗試不起作用。

回答

0

我是一名開發人員。我有一個稱爲CSV Comp Framework的完整解決方案。 他所做的: 是一個數據庫系統管理器(使用CQL的關係,採用CSV文件格式)+ CGI服務器。 適用於Linux,windows e windows ce。 桌面版是免費的(Linux和Windows)。html的例子:

<html> 
     <h1>Write your name and phone number with CSV Comp Framework</h1> 
     <form action='http://server/cgi-bin/executa/default?'> 
     Name:<br> 
     <input type='text' name='ID-name'></a></p> 

     Phone number:<br> 
     <input type='text' name='ID-phone'></a></p> 
     <!--CQL is another Query Language before Cassandra exists--> 

     <input type='submit' name='YOUR_SCRIPT.cql'></a></p> 
     </form> 
     </html> 

//the "YOUR_SCRIPT.cql" script CQL in cgi-bin 
    { 
    server-path/htdocs/YOUR_AGENDA; 
    @adicionar; 
    (ID-name;ID-phone); 
    0; 
    0; 
    0; 
    query=0; 
    destino=0 
    } 

所以,你可以使用關係從桌面到服務器,反之亦然