将R进程嵌入VBA宏中 [英] Embed an R process in a VBA macro

查看:134
本文介绍了将R进程嵌入VBA宏中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题正好-有办法从excel宏调用r进程吗?

the title exactly -- is there a way to call an r process from an excel macro?

推荐答案

我不熟悉带有r进程,但此链接似乎对您的问题有效。

I am unfamiliar with r process, but this link appears to be valid for your question.

http://www.unt.edu/rss/class/splus/UsingRWithinExcel.pdf

RExcel-在Excel中使用R

概述

Excel插件 RExcel.xla 允许在Excel中使用R。该软件包还包含一些
Excel工作簿,展示了在Excel中使用R的不同技术。
服务器有两种类型:forground和background。后台服务器ist对
用户完全隐藏,与R的所有交互都必须在Excel中完成。在Excel中工作时,前台服务器允许直接访问R GUI
命令行。 Backgound服务器与R(D)COM服务器一起安装,
后台服务器取决于{R} -package rcom,必须从CRAN安装。

The Excel addin RExcel.xla allows to use R from within Excel. The package additionally contains some Excel workbooks demonstrating different techniques for using R in Excel. There are two types of servers, forground and background. The background server ist totally hidden from the user, all interaction with R has to be done in Excel. The foreground server allows direct access to the R GUI command line while working in Excel. The backgound server is installed with the R(D)COM server, the background server depends on the {R}-package rcom, which has to be installed >from CRAN.

用法

在Excel $ b中至少有三种不同的使用R的方式$ b Scratchpad模式
直接在Excel工作表中编写R代码,并在R和Excel之间传输标量,向量和矩阵变量

There are at least three different ways of using R from within Excel Scratchpad mode Writing R Code directly in an Excel worksheet and transferring scalar, vector, and matrix variables between R and Excel

宏模式

使用VBA和RExcel.xla提供的宏编写宏,并将宏附加到菜单
项或工具栏项上

Writing macros using VBA and the macros supplied by RExcel.xla, attaching the macros to menu items or toolbar items

工作表函数

R可以直接在工作表单元格的函数中调用

R can be called directly in functions in worksheet cells

便签本模式

RExcel菜单包含以下项目:

The RExcel menu contains the following items:

R开始

启动与R
的连接如有必要,启动R进程为从Excel $ b $访问b有关在启动时执行代码的详细信息,请参见启动

Initiates a connection to R If necessary starts an R process to be accessed >from Excel For the details of executing code at startup see section Startup

关闭R

运行此过程时,R开始将更改为关闭R
运行代码
在Excel中选择包含有效R代码的范围(仅一列宽),然后选择此
菜单项将执行选定的代码

When this process is running, R Start changes to Close R Run Code Selecting a range (only one column wide) in Excel containing valid R code and then choosing this menu item executes the selected code

Get

将R变量的值添加到活动变量中Excel单元格或范围
可能的值是数字或字符串或数据框的标量和矩阵。

Gets the value of an R variable into the active Excel cell or range Possible values are scalars and matrices of numbers or strings, or dataframes.

Put

将所选Excel范围的值放入R变量。
可能的值为数字或字符串或数据帧的标量和矩阵。
如果要放置数据框,则Excel范围的第一行必须包含
数据框的变量名。
放置在数据帧中仅传输可见行和列中的数据,隐藏的行和列将不传输

Puts the values of the selected Excel range into an R variable. Possible values are scalars and matrices of numbers or strings, or dataframes. If a dataframe is to be put, the first row of the Excel range must contain the variable names for the dataframe. Put for dataframes only transfers data in visible rows and columns, hidden rows and columns will not be transferred.

复制代码

将选定范围的内容放在Windows剪贴板上(假定它是R代码),并将
的代码包装到VBA过程调用中准备将其包含在VBA宏中

Puts the content of the selected range on the Windows clipboard, assuming that it is R code, and wraps the code in VBA procedure calls to make it ready for inclusion in VBA macros

这篇关于将R进程嵌入VBA宏中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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