Reputation: 103
I have following macro with the use of Rexcel that doesn't work. I have a list of words in range A1:A2 (mydf) and i want to count the occurence of a specific word (hello) but following doesn't work well. Could someone help me understand?
Sub findwords()
Worksheets("Sheet1").Activate
rinterface.StartRServer
rinterface.PutDataframe "mydf", Range("Sheet1!A1:A200")
rinterface.RRun "a <- length(grep(hello, mydf))"
rinterface.PutArray "a", Range("Sheet1!B2:B50")
End Sub
Upvotes: 0
Views: 39
Reputation: 103
Following code is the right answer :
Sub findwords()
MsgBox "finding the word hello"
Rinterface.StartRServer
Rinterface.PutArray "mydf", Range("Sheet1!A1:A200")
Rinterface.RRun "a <- length(grep('hello', mydf))"
Rinterface.GetArray "a", Range("Sheet1!B1")
End Sub
Upvotes: 0