Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use R language in Sublime Text 2

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to use the R language in Sublime Text 2. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

Using Sublime Text 2 for R

Posted on May 17, 2012 by Tom Schenk Jr

My R interface has been pretty basic in the last few years. I have usually stuck to the R console. Yes, I've tried Emacs with ESS; a staple, but it is so unbearably antiquated that I always gave up on its significant learning curve. GUI packages-especially Rstudio-offer viable alternatives, but I feel the GUI lets me lose focus of the code. I have been envious of TextMate for Mac, but alas, I'm not a Mac user. Recently, though, I've moved to Sublime Text 2. With some nudging, I have been able to mimic the typical R console environment in the more-powerful Sublime Text program.

Want to skip to the basic instructions without the narrative? Just read the block quotes for specific instructions.

Sublime Text 2 offers a similar experience as TextMate (e.g.autocompleting parenthesis and quotation marks) and integrates well with R and other programming languages. R users aren't the primary target and it takes a little kick to get the environment perfected for the R community. This is a little tutorial to give R users a similar experience with Sublime Text without ruining the program's versatility. That is, you can have a familiar R experience and easily use Sublime Text with programming languages (e.g., JavaScript, C++) and typesetting programs (e.g.LaTeX, Markdown, MultiMarkdown).

This setup will let you

Browse R code with syntax highlighting

Use the familiar R console within Sublime Text

Send R code from a script to the R control (equivalent to Ctrl + R)

Organizing the layout so the script and console can be viewed simultaneously.

The first and last items are natively supported, but we'll need to make some additional adjustments for the second and third item.

Initial Setup

I will presume some user knowledge here and will focus on the Windows user. Setup is very easy. Their website has links to executable autoinstallers, you won't need to unzip and manual install nor are you depending on a third party to graciously compile code on your behalf.

Follow the instructions and install using the default settings.

Take a look around

Before proceeding, take a look at the R interface. Similar to other programs (e.g.Notepad++), Sublime Text offers native syntax highlighting for R code. Load one of your codes or try a sample script. If you don't see any highlighting, you can always tell Sublime Text by clicking View > Syntax and choosing R. Otherwise you can look in the lower right-hand corner as is shown in the image.

A nifty feature is autocompleting parenthesis and other special characters. Type "write.csv (" and it'll auto-insert the right paren ")". Little underlines help you match each left parenthesis with the right parenthesis. It also works with "{", "[", single, and double quotation marks.

Comments have a lighter tone. So does the ubiquitous "

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report