首页 文章

如何在powerpoint(VBA)上运行R脚本文件

提问于
浏览
1

我有这个脚本文件:

library(fBasics) # Load the package fBasics.
da=read.table("C:\\Users\\jose\\Tese\\Analysis of Financial Time Series\\dibm3dx7008.txt",header=T) # Load the data.

dim(da) # Find size of the data: 9845 rows and 5 columns.
da[1,] # See the first row of the data

ibm=da[,2] # Obtain IBM simple returns
sibm=ibm*100 # Percentage simple returns
basicStats(sibm) # Compute the summary statistics

我想从powerpoint运行它;我在powerpoint上尝试过VBA,任何人都可以帮助我

2 回答

  • 1

    不是你的问题的直接答案,但你可能会看看使用Sweave(或knitr)与beamer幻灯片 .

  • 1

    您可以将脚本放入* .bat文件,然后通过Shellexecute从Powerpoint执行此操作 . 但这是一种可怕的痛苦,并且极易受到更改文件位置的影响 .

    一些代码:

    Dim wshshell As Object
    Set wshshell = CreateObject("WScript.Shell") 'a shellconsole
    Dim Shellscript as String
    ShellScript = "c:\yourscript.bat" 'if this contains white spaces you have to add chr(34)  at the beginning and end of the string.
    
    wshshell.CurrentDirectory = YourProgramPath 'set the current directory
    wshshell.Run shellscript, , True 'run the script
    
    'then parse the results -sorry I have no idea how to do this in R.
    

相关问题