iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 3
0
Data Technology

Microsoft R Solution系列 第 3

Day03 - Microsoft R Open and R Tools for Visual Studio

  • 分享至 

  • xImage
  •  

在安裝Microsoft R Open and R Tools for Visual Studio之前, 先來安裝一般R的開發環境, 首先到底下位置點擊下載
https://cran.r-project.org/bin/windows/base/
https://ithelp.ithome.com.tw/upload/images/20171221/20103333k6fXhDKrws.png

執行下載檔案, 毫無懸念一路下一步安裝到底, 惟需留意一下R的安裝目錄, 方便日後切換不同版本R的位置
https://ithelp.ithome.com.tw/upload/images/20171221/20103333uyHHufV2bN.png

接著安裝筆者慣用的 RStudio, 首先到底下位置點擊下載
https://www.rstudio.com/products/rstudio/download/#download
https://ithelp.ithome.com.tw/upload/images/20171221/20103333e4a4WcMOMa.png

一樣是下一步安裝到底, 安裝完成之後,打開RStudio如下, 紅色框的部分代表目前執行的R版本
https://ithelp.ithome.com.tw/upload/images/20171221/20103333RZ3YviBnxN.png

在安裝Microsoft R Open之前, 也許有人會想”不是已經安裝R了, 為何還需要裝Microsoft R Open?”, 答案是為了效能, 因為原生的R只能跑單執行緒(single thread), 底下是官方的比較表
https://ithelp.ithome.com.tw/upload/images/20171221/20103333yFUnxcwwZl.png
132.96 vs 2.92是不是很驚人呢?

Microsoft R Open的下載位置如下
http://mran.microsoft.com/download/
https://ithelp.ithome.com.tw/upload/images/20171221/201033331UOAkVzTun.png

一樣一路下一步安裝到底, 注意一下安裝目錄
https://ithelp.ithome.com.tw/upload/images/20171221/20103333oPHADWuLUE.png

此時重新開啟RStudio, 會發現已經套用了Microsoft R Open
https://ithelp.ithome.com.tw/upload/images/20171221/20103333632eR2r42p.png

若日後想切回原生R的版本, 可以到Tools的頁籤下找到Global Options
https://ithelp.ithome.com.tw/upload/images/20171221/20103333wXySTIC2Vs.png

之後按下Change就能選取其他R版本的安裝目錄切回去了
https://ithelp.ithome.com.tw/upload/images/20171221/20103333GmNAhuxzOb.png

最後就是來安裝RTVS(R Tools for Visual Studio), Visual Studio 2015版本到下列網址下載
https://www.visualstudio.com/zh-hant/vs/rtvs/
https://ithelp.ithome.com.tw/upload/images/20171221/201033332p77u54TXb.png

若是Visual Studio 2017, 請開新專案, 找到Open Visual Studio Installer打開來
https://ithelp.ithome.com.tw/upload/images/20171221/20103333fiUDL4XtvL.png

或是直接打開Visual Studio安裝程式亦可, 確認Data science and analytical applications是否勾選安裝?
https://ithelp.ithome.com.tw/upload/images/20171221/201033334QQ8EVm58R.png

到此也有人會想, 都有RStudio這麼棒的IDE了, 而且也支援Github與SVN的版本控管, 為什麼需要RTVS呢?/images/emoticon/emoticon19.gif 當然對R單一開發者來說, RStudio絕對是夠用的, 但是對於.Net的開發者來說, R可能是整個方案中的一個專案而已, 若所有的開發測試工作都能在Visual Studio完成, 就不需要在不同的IDE切來切去, 所有專案都能進TFS(Team Foundation Server) 或VSTS(Visual Studio Team Services) 統一管理, 更方便省事.

安裝完畢之後, 可以來調整Visual Studio的設定, Tools頁籤下, 點擊Import and Export Settings
https://ithelp.ithome.com.tw/upload/images/20171221/20103333yjec0GvzkY.png

選擇Reset all settings, 並且按下Next
https://ithelp.ithome.com.tw/upload/images/20171221/20103333pK3XyLdfuq.png

點選如紅框所示, , 並且按下Next
https://ithelp.ithome.com.tw/upload/images/20171221/20103333kRYeG7CZZF.png

看到紅框, 是不是覺得RTVS很貼心?/images/emoticon/emoticon24.gif 有支援RStudio 快捷命令, 點選之後, 按下Finish
https://ithelp.ithome.com.tw/upload/images/20171221/20103333A3kwPwEi3M.png

接下我們建立新的R專案, 按下OK
https://ithelp.ithome.com.tw/upload/images/20171221/20103333R6CG7GOcxh.png

整個視窗是不是跟RStudio有87分像, 除了Visual Studio一貫風格的Intellisense外, 直接按下F1如同在RStudio般, 直接叫出R Help查看
https://ithelp.ithome.com.tw/upload/images/20171221/20103333tQbJqnp1WU.png

下一篇我們就來實測一下Microsoft R Open的執行速度是不是讓原生的R看不到車尾燈阿?/images/emoticon/emoticon07.gif

本文參考網址
https://mran.microsoft.com/documents/rro/multithread/


上一篇
Day02 - Microsoft R Solution
下一篇
Day04 - 實測Microsoft R Open
系列文
Microsoft R Solution30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

0
CyberSerge
iT邦好手 1 級 ‧ 2017-12-27 05:34:23

我之前也覺得為什麼有RStudio還要Visual Studio,現在懂了:)

arksu iT邦新手 2 級 ‧ 2017-12-27 09:53:49 檢舉

其實一切都是M$的陰謀啦/images/emoticon/emoticon01.gif

我要留言

立即登入留言