rexcel

Populating Excel Macro-enabled cells from R/outside environment

☆樱花仙子☆ 提交于 2019-12-31 07:41:08
问题 I have a macro-enabled template in excel that I wish to populate programmatically from R. I have an R process that retrieves different set of data for every item I with to process, processes them, and then I want it to duplicate and populate the template for each data set, bypassing the need to fill the template out by hand for every set of data. I have been using the XLConnect R package, however it does not support .xlsm files. I thought about using RExcel, but I want to run the program from

writing VBA code to call R script

我的梦境 提交于 2019-12-08 13:01:52
问题 I've downloaded and installed Rconn as well as Rexcel. The API appears to be working as I am able to copy my code from R into Excel and then, through the use of the API GUI I am able to extract values for one of my matrices. The problem I'm having is within VBA. When I try and run the following line: RInterface.StartRServer I get the following error message: "Run-time error'424': Object required" Would anyone be able to help me understand why I'm getting this error? Am I perhaps meant to load

Run R function in VBA macro

女生的网名这么多〃 提交于 2019-12-05 08:14:56
问题 I'm trying to run a R code from excel VBA macro. The R function is using two inputs: DataFilter(Input1,Input2) The function does some filtering and then saves a new excel file in the folder N:\DataFolder Can you please help in creating an VBA macro that runs the DataFilter function with two new text inputs (lets say cells A1 and B1 from the sheet1 in the spreadsheet). From there I will be able to open the excel file in the vba macro. Thank you! 回答1: You can run an R script in VBA by creating

RExcel in R 3.0.x

自作多情 提交于 2019-12-04 09:42:47
问题 RAndFriends, which includes all the items needed to run RExcel , includes just R 2.15.2 . I am currently using the latest version of R but rcom 2.3.1 and rscproxy 2.0.5 , which I am currently using, do not allow me to start an R server within Excel. Setting foreground R server whithin Excel returns a fatal error and R rejects any connection with Excel via rcom . I get two error messages: R Server not available There seems to be no R process connected to Excel The main difference with a

Run R function in VBA macro

*爱你&永不变心* 提交于 2019-12-03 22:00:41
I'm trying to run a R code from excel VBA macro. The R function is using two inputs: DataFilter(Input1,Input2) The function does some filtering and then saves a new excel file in the folder N:\DataFolder Can you please help in creating an VBA macro that runs the DataFilter function with two new text inputs (lets say cells A1 and B1 from the sheet1 in the spreadsheet). From there I will be able to open the excel file in the vba macro. Thank you! You can run an R script in VBA by creating Windows Shell obejct and passing it a string that executes an R script Sub RunRscript() 'runs an external R

Run macro with Rexcel

谁都会走 提交于 2019-12-02 17:24:57
问题 I am running a macro with Rexcel in VBA: Sub create_efficient_frontier() RInterface.StartRServer Sheets("Analys").Range("A52:K82").ClearContents RInterface.PutDataframe "datat", Range("ChosenData!X181:AD352") RInterface.PutArray "startdate", Range("Analys!K2") RInterface.PutArray "enddate", Range("Analys!K3") RInterface.RunRFile "C:/Users/Documents/EffFront.R" RInterface.GetDataframe "hmz$pweight", Range("Analys!A51:E76") End Sub The sourced R code is: myfront=function(datat,startdate,enddate

Populating Excel Macro-enabled cells from R/outside environment

半腔热情 提交于 2019-12-02 13:26:09
I have a macro-enabled template in excel that I wish to populate programmatically from R. I have an R process that retrieves different set of data for every item I with to process, processes them, and then I want it to duplicate and populate the template for each data set, bypassing the need to fill the template out by hand for every set of data. I have been using the XLConnect R package, however it does not support .xlsm files. I thought about using RExcel, but I want to run the program from an R environment, not from within Excel (also I had many difficulties trying to install RExcel). This

Run macro with Rexcel

烂漫一生 提交于 2019-12-02 12:45:09
I am running a macro with Rexcel in VBA: Sub create_efficient_frontier() RInterface.StartRServer Sheets("Analys").Range("A52:K82").ClearContents RInterface.PutDataframe "datat", Range("ChosenData!X181:AD352") RInterface.PutArray "startdate", Range("Analys!K2") RInterface.PutArray "enddate", Range("Analys!K3") RInterface.RunRFile "C:/Users/Documents/EffFront.R" RInterface.GetDataframe "hmz$pweight", Range("Analys!A51:E76") End Sub The sourced R code is: myfront=function(datat,startdate,enddate){ library(fPortfolio) datat=datat[startdate:enddate,] datanew=datat[sapply(datat[1,], function(x) !any

Error with Rexcel when starting up Excel

我是研究僧i 提交于 2019-11-29 18:13:58
Today something happened (never had this problem before) when I start up Excel workbook where I use Rexcel. And then there are some more errors... Everything worked properly before.. Does anyone have an idea about what the problem could be? The other strange thing is that after that the Rapply and so on works.. But I get errors again when I close workbook. So the problem appears when I startR from Rexcel meny in Excel. EDIT: Thanks to flodel for his answer. But is it not possible to run the Sub below now or? Sub create_efficient_frontier() RInterface.StartRServer Sheets("Analys").Range("A52

Run R script in Excel

纵然是瞬间 提交于 2019-11-29 12:01:39
There isn't a lot of information on how to do this. I tried to study a blog online and implemented the following code in VBA(with the path of the R file):- Sub RunRscript() 'runs an external R code through Shell 'The location of the RScript is 'C:\R_code' 'The script name is 'hello.R' Dim shell As Object Set shell = VBA.CreateObject("WScript.Shell") Dim waitTillComplete As Boolean: waitTillComplete = True Dim style As Integer: style = 1 Dim errorCode As Integer Dim path As String path = "RScript C:\R_code\hello.R" errorCode = shell.Run(path, style, waitTillComplete) End Sub Source However,