如何在R中使用msgbox [英] How to use msgbox in R

查看:104
本文介绍了如何在R中使用msgbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在R中显示一个消息框?

How can I display a message box in R ?

我正在寻找类似于VBA中的msgbox的内容,因此,例如,我可以警告用户有关问题.

I'm looking for something similar to msgbox in VBA, so I can for example alert the user about a problem.

此外,我想允许一些用户交互.因此,例如,我可以问用户该程序应该使用哪一天.

Additionally I would like to allow some user interaction. So for example I could ask the user what day the program should use.

推荐答案

您要确切地做什么?我想到两件事.

What do you want to do exactly? Two things come to mind.

您可以在R中使用tcl/tk包来创建UI.从此处查看带有代码的示例: http://www.sciviews.org/_rgui/tcltk/.该软件包提供了快速简便的功能来创建消息框,小部件以及其他简单或复杂的UI.几年前,我为不熟悉R的用户创建了一个指向R的点击流水线,用于在R中生成绘图.我相信该软件包已经安装了较新版本的R.

You can use the tcl/tk package in R to create a UI. See some examples with code from here: http://www.sciviews.org/_rgui/tcltk/. This package provides quick and easy functions to create message boxes, widgets, and other simple or complicated UIs. I created a point and click pipeline for producing plots in R using this package a couple years ago for users that were unfamiliar with R. I believe that this package is already installed with newer versions of R.

这是一个非常简单的示例,您可以尝试:

Here is a very simple example you can try:

require(tcltk)
msgBox <- tkmessageBox(title = "Title of message box",
                       message = "Hello, world!", icon = "info", type = "ok")

您还可以创建消息框,接受来自用户的输入,以供以后使用,等等.请访问我链接的网站,获取示例列表,以帮助您入门.

You can also create message boxes that accept inputs from the user that you can use later, etc. Check out the website I linked for a list of examples to get you started.

接下来,我们有了更新的Shiny界面,该界面可以要求用户输入并通过Web动态生成输出,尽管它要先进一些.它通过一些简单的R代码在您的浏览器中提供了一个用户界面,并且后端也是使用R代码创建的.不需要javascript或html即可进行简单的设置,但是对Shiny应用程序进行编码需要一点学习.您只需在本地计算机上安装shiny软件包即可轻松创建本地Shiny应用程序,但是需要进行一些设置才能设置服务器以将R应用程序部署到本地系统之外.如果您想通过网络部署R Shiny应用程序,RStudio团队会在其服务器上提供免费帐户.请访问 http://www.rstudio.com/shiny/以获得一些示例,您可以找到 http://rstudio.github.io/shiny/tutorial/上的教程.

Next, we have the newer Shiny interface, which can ask for user input and produce output dynamically over the web, though it is a little more advanced. It provides a user interface through your browser through some simple R code, and the backend is created using R code as well. No javascript or html is required to get a simple set up going, but there is a slight learning curve for coding the Shiny app. You can easily create local Shiny apps by simply installing the shiny package on your local machine, but some set up is required to set up a server to deploy your R app outside of your local system. The RStudio team is offering free accounts on their servers if you want to deploy your R Shiny app over the web. Go to http://www.rstudio.com/shiny/ for some examples, and you can find tutorials at http://rstudio.github.io/shiny/tutorial/.

这篇关于如何在R中使用msgbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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