我在大学用Vim在Windows中编写Stata脚本已经有一段时间了。我现在正在学习R,我想完全改用Linux作为我的操作系统(我最近在笔记本电脑上换成了Ubuntu)。R在Windows和Linux中都可以很好地与Vim配合使用,但是有时我仍然需要使用Stata。在Windows中,我一直在使用Stata用户提供的一个简单的AutoIt脚本将行/整个文件发送到Stata进行评估。这个脚本在Linux中不起作用。在
这就是剧本的样子
; AutoIt v3 script to run a Stata do-file from an external text editor
; Version 3.1, Friedrich Huebler, fhuebler@gmail.com, www.huebler.info, 30 March 2009
; Declare variables
Global $ini, $statapath, $statawin, $dofile, $winpause, $keypause, $clippause
; File locations
; Path to INI file
$ini = @ScriptDir & "\rundo.ini"
; Path to Stata executable
$statapath = IniRead($ini, "Stata", "statapath", "C:\Program Files\Stata10\wsestata.exe")
; Title of Stata window
$statawin = IniRead($ini, "Stata", "statawin", "Stata/SE 10.1")
; Path to do-file that is passed to AutoIt
; Edit line to match editor used, if necessary
$dofile = $CmdLine[1]
; Delays
; Pause after copying of Stata commands to clipboard
$clippause = IniRead($ini, "Delays", "clippause", "100")
; Pause between window-related operations
$winpause = IniRead($ini, "Delays", "winpause", "200")
; Pause between keystrokes sent to Stata
$keypause = IniRead($ini, "Delays", "keypause", "1")
; Set SendKeyDelay and WinWaitDelay to speed up or slow down script
Opt("WinWaitDelay", $winpause)
Opt("SendKeyDelay", $keypause)
; If more than one Stata window is open, the window
; that was most recently active will be matched
Opt("WinTitleMatchMode", 2)
; Check if Stata is already open, start Stata if not
If WinExists($statawin) Then
WinActivate($statawin)
WinWaitActive($statawin)
; Activate Stata Command Window and select text (if any)
Send("^4")
Send("^a")
; Run saved do-file
; Double quotes around $dofile needed in case path contains blanks
ClipPut("do " & '"' & $dofile & '"')
; Pause avoids problem with clipboard, may be AutoIt or Windows bug
Sleep($clippause)
Send("^v" & "{Enter}")
Else
Run($statapath)
WinWaitActive($statawin)
; Activate Stata Command Window
Send("^4")
; Run saved do-file
; Double quotes around $dofile needed in case path contains blanks
ClipPut("do " & '"' & $dofile & '"')
; Pause avoids problem with clipboard, may be AutoIt or Windows bug
Sleep($clippause)
Send("^v" & "{Enter}")
EndIf
; End of script
在我的vimrc中有以下内容
^{pr2}$这真的很实用,实际上也是我仍然坚持用窗户的唯一原因。我该怎么为Ubuntu买这样的东西呢?我是linux新手,除了统计之外,我对编程不太了解。非常感谢任何帮助。 (请不要建议emacs,emacs对stata的支持是错误的,尽管它与R的集成要好得多,但我现在还是想继续使用Vim。)
关于一个可能相关的主题:我正在考虑学习Python,因为我可能要处理数据和进行更长时间的实证分析,我认为它可能对某些任务有用,例如解决此类问题或解析网站上的数据。这是推荐的,还是我应该看另一种语言(或者完全忘记这个想法)?在
如果你打算改用linux(永远),你应该 1调用stata并将您的许可证切换到linux许可证(他们将免费提供)并在本机安装,然后从vim启动stata只需要一个bash脚本(我不是vim专家) 2或者,你可以购买Stata11,它对所有支持的平台都有一个许可证 三。你可以用wine安装stata(在linux上玩会让我更容易),但是我不能让wine给stata提供超过半个gig的ram,所以我安装了native stata10
我对python、stata、R、latex等使用gedit,它可以处理任何事情,gtksourceview很容易添加语法高亮显示和样式等。。在
Python非常适合数据分析,请参见
http://www.scipy.org/ http://openopt.org/Welcome http://www.macworld.com/appguide/app.html?id=63924&expand=false
为了抓取网站
http://scrapy.org/ http://wwsearch.sourceforge.net/mechanize/在
对于从文本中分析数据,我们通常有, http://pyparsing.wikispaces.com/
我有一堆你可能会觉得有用的文件(gtksoureview语言定义stata和其他一些,一些书籍的pdf副本(有些是copyleft)),但我不知道如何在这个网站上附加文件
在linux中,您可以使用一个名为vim的插件粘液这将允许您在不离开vim的情况下将代码从vim传递到正在运行的R进程。我在macformysql、php、python和ocaml上使用它,效果非常好。唯一需要注意的是,它使用屏幕来实现它的魔力,这本身并不是一件坏事。在
如果我能正确地理解你的问题,我相信这将对你有很大的帮助。祝你好运,希望对你有帮助。在
[编辑]:哎呀,我注意到你的主要问题与AutoIt脚本有关,对不起,我不知道如何将其翻译成Linux。我觉得没有什么简单的办法。您可能希望了解xautomation或其他类似的工具,但这是完全不同的游戏。在
在
.vimrc
中替换:使用在linux中执行相同操作的命令。 它应该与此类似:
^{pr2}$因为我不知道斯塔塔的事,你得从别人那里找出确切的命令。在
另外,我不确定
"%:p"
:请在vim帮助中查找并比较Windows和Linux之间的差异。在相关问题 更多 >
编程相关推荐