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, when I run the macro in Excel, it basically does nothing-just opens the script in RStudio. I am not getting any error, but it's not giving any output-just opens the R script in Rstudio. What am I doing wrong?
Also, does this method work or basically I need to install the software RExcel, if I need to use R in Excel?
Any other link/information to use R in Excel would be appreciated. Thanks:)