R 脚本的 GUI 前端 [英] GUI frontend for R script

查看:41
本文介绍了R 脚本的 GUI 前端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一组 R 脚本,它们处理一些数据并产生一些结果.我们希望将这些脚本提供给不习惯 R 命令行的基本用户 - 我们希望为他们提供一些漂亮的 GUI,这将允许:

We have a set of R scripts, which process some data and produce some results. We want to make these scripts available to basic users, which are not used to commandline of R - we want to provide them some nice GUI, which would allow to:

  • 轻松从 MS Excel/Access 导入/导出数据(如果可能,还支持复制/粘贴)
  • 允许用户更改进程的设置/参数
  • 应该在 MS Windows 中运行.

是否有任何简单的脚本环境可以让我们尽快为我们的 R 脚本开发如此漂亮的 GUI?不一定是 R 语言.

推荐答案

RExcel 工具将 R 整合为 Excel 插件,因此主界面是 Excel,R 在后台进行计算.您可以设置一个工作表,以便用户输入他们的数据,然后突出显示一个框,然后选择一个菜单项或单击一个按钮,结果将放置在另一个单元格(或一组单元格)中.但是请注意,RExcel 及其用户的通信程序不是免费的.

There is the RExcel tool that incorporates R as an Excel plugin so the main interface is Excel with R doing the computations in the background. You could set up a sheet so that the user enters their data, then highlights a box and then chooses a menu item or clicks a button and the results are placed in another cell (or set of cells). Note however, that RExcel and the comunication program it user are not free.

另一种选择是在 R 中创建您自己的 gui 函数,然后在您启动 R 时让该 gui 自动运行(请参阅?STARTUP)并在用户计算机上进行设置.我之前为客户做过这件事,对 R 一无所知,他们只是双击桌面(窗口)上的图标,打开主 R 窗口时将其最小化,与我编程运行的 gui 交互(我使用 tcltk,但还有其他)并看到提供的输出.

Another option is to create your own gui function in R, then have that gui run automatically when you start R (see ?STARTUP) and set this up on the users machine. I have done this for clients before that did not know anything about R, they just double clicked on the icon on the desktop (windows), minimized the main R window when it opened, interacted with the gui that I had programmed to run (I used tcltk, but there are others) and saw the output provided.

您可以通过让用户选择数据并单击复制来从 Excel 复制数据,然后在您的程序中运行 newdata <- read.delim('clipboard') 并且数据将在名为 'newdata' 的数据框中,您可以使用 write.table(outdata, file='clipboard', delim='\t') 将数据框 'outdata' 中的数据放到剪贴板,然后用户可以将其粘贴到 Excel(或其他程序)中.

You can get data copied from Excel by having the user select the data and click on copy, then in your program run newdata <- read.delim('clipboard') and the data will be in the data frame called 'newdata', you can use write.table(outdata, file='clipboard', delim='\t') to put the data from data frame 'outdata' onto the clipboard and the user can then paste it into Excel (or other programs).

还有 Rcmdr 包,它为 R(基本工具)提供通用 GUI,但也有一个机制,您可以创建自己的菜单和对话框以与 GUI 一起使用.

There is also the Rcmdr package which provides a general GUI for R (basic tools) but also has a mechanism where you can create your own menus and dialog boxes for use with the GUI.

这篇关于R 脚本的 GUI 前端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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