反应性地写2个元素到一个csv文件 [英] reactively writing 2 elemenst to a csv file

查看:280
本文介绍了反应性地写2个元素到一个csv文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个用户在掷骰子中获得的结果,以及他在一个CSV文件中点击扔按钮的时间,我可以在以后访问。

I am trying to write the result the user gets in a dice throw and the time he hits the throw button in a CSV file which i can access later at my own time.

我从以下示例中借用了代码( R / Shiny - 如何写一个.csv反应性地包括一个actionButton?),但我不能合并一个以上的反应动作。因为在中可以得到代码写结果到一个csv文件,但是当我调用函数来获取开始时间我得到以下错误 - Listening on http://127.0.0.1:6949
.getReactiveEnvironment()中的错误$ currentContext():
在没有活动反应上下文的情况下不允许操作做一些只能从一个反应式表达式或观察者内部完成的事情。)

I have borrowed code from the following example(R/Shiny - How to write a .csv reactively including a actionButton?) ,but i am unable to incorporate more than one reactive actions. As in can get the code to write the result to a csv file,but when i call the function to get the start time i get the following error-"Listening on http://127.0.0.1:6949 Error in .getReactiveEnvironment()$currentContext() : Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)"

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()函数放在闪烁的体外并触发与全局变量。我尝试通过使用<< - 运算符,从使用actionbuttion分配值到这个全局变量,但尝试没有工作。

I tried to put the getstart() function outside the shiny body and trigged to trigger it with a global variable . I tried to assign the value to this global variable from the use of the actionbuttion by using <<- operator,but the attempt did not work.

推荐答案

我是一个开发人员。我有一个名为CSV Comp Framework的完整解决方案。
他做什么:
是一个数据库系统管理器(使用CQL的关系,以CSV文件格式)+ CGI服务器。
在Linux,windows e windows ce上工作。
桌面版是免费的(linux和windows).html示例:

I'm a developer .I have a complete solution called CSV Comp Framework. what he does: is a Database System Manager (Relational using CQL ,in CSV file Format) + CGI server. works on Linux,windows e windows ce. the desktop version is free ( linux and windows ).html example:

    <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
   }

到服务器,反之亦然。

这篇关于反应性地写2个元素到一个csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆