I realise there are a few threads that already exist with regards to the second half of my question, but they don't seem to address the problem.
I am using R-Box, SendText, and SendCode to send lines of code from Sublime Text 3 to the R-GUI. However, I prefer working in Rterm rather than the GUI. Is there a way to modify settings in any of the three sublime text packages to send code to Rterm.exe instead?
In the mean time, I recently got a new laptop and can't seem to get Sublime Text 3 to send code to SublimeREPL properly. It decides to send the occasional line, but will not send some for no reason. Any ideas how to fix it?
Thanks in advance for your help.
I made Sublime/R-Box/SendCode work with Rterm by changing the settings in the RGui to SDI.
In RGui > Gui Settings > Select "SDI" > Click on "Save" > Close R Gui (this will show a warning)
Reopen R Gui to check that it opens Rterm.
In Sublime, working with SendCode/R-Box then will open the Rterm.
Use the standard settings in SendCode (In Sublime: Crtl+Alt+P > SendCode: Choose Program > Select "R Gui"), it works with R Term.
Note: You must open Rterm manually before using it from Sublime.
Let me know, please, if that worked for you.
Related
According to most articles on R the terminal simply shows up as a tab next to console in R or can be opened with shift+alt+R, however i still do not get anything
a picture of the workspacel do not get the terminal.
The "terminal"-tab next to "console" is for RStudio and you are not using RStudio. Thats why you cant use the Shortcut.
I have just switched from windows 7 to windows 10 on my pc.
When I was still using windows 7, using the combination CTRL+R or CTRL+ENTER would run the line of code that I was in. Moreover, if the code continued on one or more lines below or started above my current line, it would run the entire section without me having to select it.
After switching to windows 10, the same combinations will only run the line of code that I am currently in, or the piece of code that is selected by me. To give an example:
#Tryout
for(i in 1:3){
print(i)
}
This code would normally run at once without having to select it, even when I would start in the first line (#Tryout). Now, if I don't select, I will need to use CTRL+R or CTRL+ENTER three times to go through this code and I have to start in the correct line. Starting in the line #Tryout will not run any part of the code but will only result in the line #Tryout being shown in the console.
I'm not good with computers (in your answers please pretend to be adressing a five-year-old) so I had one of my colleagues look at it who's our expert on R. Here are the findings:
The problem occurs in both RStudio as the standalone version of R.
I'm using R version 3.3.2, the same as before the windows update. Switching to version 3.5 didn't solve the problem.
I have other colleagues also using R 3.3 in combination with windows 10 for whom this problem does not occur.
Going to Tools-Global Options-Code and checking the box of 'Focus console after executing from source' doesn't help
When we went to 'Modify Keyboard Shortcuts', the name attached to the shortcut (CTRL+R or CTRL+ENTER) was the same as it was for other colleagues for which the function does run all lines in a command: 'Run Current Line or Selection'
The problem is not preventing me from using R, but it is tedious and I hope someone can help me to solve it.
Thanks so much for reading!
Click on header Tools, then Global Options..., then Code, then Ctrl + Enter Executes and choose Multi-line R statement
#M Waz & #Just Burfi: I know I can select the code and then run it, that works fine. But I don't want to have to manually select the code all the time.
#Clemsang: your answer puzzled me for a moment because I didn't have the CTRL + Enter Executes that you were referring to. I went back to my colleague who had the bright idea to check the version of RStudio that I was using.
As it turns out, I was using an old version (0.99.903). Now that I've installed a newer version (1.1.463), running the code works as before! I also have the CTRL + Enter Executes now.
I'm doing some very basic commands in RStudio (in Windows 10), and suddenly/randomly the command prompt ">" disappeared. This is not the first time this has happened for me. Pressing escape, enter, or anything else doesn't get me back the >. Moreover, when I try to close RStudio, it just stays on "quitting r session" and never closes. I tried to embed a screen shot of the console I'm seeing, but I'm not sure if it worked. If anyone can help me with this issue (being able to get back the > and execute commands again) or direct me to another post where this was addressed, I would really appreciate it (otherwise I have to restart my whole system every time to fix it).
In R I always like to print out the script since it gives a good overview and one can adjust eventual errors. I like the syntax highlighting in R-Studio because it facilitates reading and fast comprehension of code.
Is there a way to print out the text with the highlighting I see in the editor?
Its not an R-Studio solution, but notepad++ will print R source with syntax highlighting.
RStudio will not print in colour, but it's easy to save the code as a PDF; in this case the syntax format is preserved. My favourite package is knitr.
library(knitr)
stitch("file_name.R")
The default output is PDF/Markup in .tex. If you prefer not to typeset, running the below will export as .html
stitch(script="file_name.R", system.file("misc", "knitr-template.Rhtml", package="knitr"))
Brief explanation
The reason this is an answer to this question in because of the last line of the question:
Is there a way to print out the text with the highlighting I see in
the editor?
so we are not limited to only and only using Rstudio software here.
After exploring the awesome answer by #rrg and realizing that it runs the code line by line, I wrote a comment below his answer and continued googling. My problem is that the code I wrote is so large and so time consuming to run that running it for the sake of having a syntax highlighted version is not feasible.
Most of the solution out there online involves having notepad++ which is a Windows application and I'm a dedicated Linux user, so I searched for a way I can do this in Linux (and possibly Mac)
The way I solved it:
Inspired by a blog post, I used the famous and beloved Vim to convert R to syntax highlighted HTML and then because you can open HTML in your browser, you can what ever you want with it (print, screenshot, etc.)
Activate synax highlighting in Vim:
open terminal
then open the vim config file by typing vim ~/.vimrc
press i from keyboard to go to "insert mode"
go to the end of the file using arrow keys on your keyboard
type syntax on at the end of the file
now you need to save and exit. For this you need to press Esc button from keyboard to come out of "insert mode" and then type :x and press Enter to save and close the file.
if you want to change the color scheme of the syntax highlighting, visit the bottom part of this website
From terminal open your file with Vim:
vim YOUR_FILE_PATH
Having you R code open in vim, you can turn on the line numbers if you like by pressing Esc and then write :set number and press Enter.
For converting R to HTML, press Esc to make sure you are not in "insert mode" and then type :TOhtml and press Enter. This will result is having a split window in terminal, half is your R code and the other half id your new HTML code.
For saving the files, type :x along with Enter button from keyboard twice to save both files (your R file will be unchanged if you have not typed anything extra in it and your HTML file will be created with the same name near your R code)
Now open it with your favorite browser (in my case Vivaldi) and do what ever you want (in my case converting the whole HTML into PNG)
Best way:
download https://github.com/jaredpetersen/codeprinter and paste in the r code. then choose syntax highlighting Xcode
For those using a Mac (and thus without access to Notepad++) cutting and pasting into Xcode and printing from there will also work.
As with Ron Jensen's earlier comment, this isn't an R Studio solution, but in the interests of "just getting it to work", I hope this helps someone.
Super basic question here:
I installed the R-box package in Sublime 3 with no problems.
I changed the path to my R.app in the SublimeREPL.sublime-settings in Sublime, although this should not make a differece on Mac.
I checked in Package Control -> R-Box:Select Program. It's set to R.
I'm simply unable to get Sublime to send code to R. Pressing Cmd+Enter does nothing (actually, it starts a new line on Sublime).
I'm running Sublime 3 on Maverics, and R version 3.2.1. But I had the same problems with Sublime 2 and a previous R version. I'm sure I'm missing something simple but I can't find any more information in the installation page.
Open up an R console by pressing Ctrl+Shift+P and typing REPL R (after a few times you’ll be able to just type R and it will come up). You can open up two windows using (Alt+Shift+2) so you can have your R code on the left and your R console on the right.
As for running the code, once you have called the R console, you have three options: To run the current line or your selected lines, press Ctrl+Shift (release) then l. To run just the selected text, press Ctrl+Shift (release) then s. To run the entire file, press Ctrl+Shift (release) then f.
Actually, I got an answer from the R-box developers, that worked perfectly:
Close Sublime Text 3, then reopen it. Then check that at the bottom right of the window it says R Extended.
If not, you need to set the Syntax on the file:
cmd+shift+P
Set Syntax: R Extended