Command line arguments R script using Tinn-R - r

How can I use command line arguments with a R script using Tinn-R.
I can give arguments with a R script like this:
R.exe --args 2010 test.R
And after that read them in the script with commandArgs.
But how can I provide them when using Tinn-R? I cannot find anything in the Tinn-R help

Take a look at this:
SourceForge - Helppages for Tinn

Give a looked in the picture attached below.
I think it should solve your question.

Related

How to suppress output in RStudio?

I need to suppress my output when I run my R scripts in RStudio. There are a lot of comments in my scripts, and the comments are printed when I run the file.
I realize that others have asked how to do this from the command prompt - How to suppress output. I'm not interested in that.
I just want to know how to suppress the output in RStudio. The only exception to this should be print statements. Thanks in advance.
Use source instead of source with echo in R Studio.
Same in MAC.
Ctrl+Shift+S will do the trick. In mac, it will be Shift+Command+S.

R Run knitr from a batch-file (windows)

I run some automatic reports each day with batch-files on my windows-computer. But how do I do this with a .rmd file and generate the html-output?
So, this works for me using a batchfile with a normal .R file:
"C:\R\R-3.0.1\bin\x64\Rscript.exe" --default-packages=methods
"C:\R\R-3.0.1\bin\x64\Scripts\models.R"
But, this won't:
"C:\R\R-3.0.1\bin\x64\Rscript.exe" --default-packages=methods,knitr
"C:\R\R-3.0.1\bin\x64\Scripts\test_knitr.Rmd"
I've tried some variations inspired by command-line like:
"C:\R\R-3.0.1\bin\x64\Rscript.exe" --default-packages=methods,knitr
knit("C:\R\R-3.0.1\bin\x64\Scripts\test_knitr.Rmd")
But no succes so far! Im a total knitr/.rmd newbee, so I'm not even sure it can be done.
I use something along the lines
Rscript -e "require ('knitr'); knit ('test.Rmd')"
I use
"C:\Program Files\R\R-3.5.1\bin\Rscript.exe" -e "library('knitr'); knit('C:/Users/test_doc.Rmd')"
pause
Like "cbeleites supports Monica" said using the full path.
Don't forget that in R we must use "/" and not "\" like in Windows.
So in the R call we use "\" because we are talking to Windows
and in the knit we use "/" because we are talking to R.
I hope it help.

R syntax highlighting in Terminal

Can we get syntax highlighting for R in the Terminal?
I've finally found a library that meets my needs.
Now I'm much happier with my coding environment.
colorout is an R package that colorizes R output when running in a terminal emulator.The package cannot be on CRAN because it changes code already loaded by R and this is prohibited by the CRAN Repository Policy. The package replaces the functions that output results and messages to R Console, and this is necessary because we cannot colorize the output without replacing these functions. To install it, do the following in R:
install.packages("devtools")
devtools::install_github("jalvesaq/colorout")
library("colorout")
# do something
Use something like ess on emacs or RStudio for syntax highlighting for R instead of expecting it to work in the terminal.
Another option now would be to use radian instead of the default R prompt.
As hd1 indicated, this is not an R question. You're asking the OSX Terminal.app to do something it's not capable of. A quick look around Google (happy Zamboni birthday!) shows Vim syntax Highlighting for highlighting within vim , or https://superuser.com/questions/72057/terminal-emulator-with-custom-color-palette , but dunno if these will run under Darwin.
EDIT: I can't stay away from the search :-) . So check out these threads: https://superuser.com/questions/400360/syntax-highlighting-in-terminal-mac-os-x , http://forums.macrumors.com/showthread.php?t=412609 , and a recommendation to install zsh , https://apple.stackexchange.com/questions/12161/os-x-terminal-must-have-utilities

Sourcing script does not print any output to the console

I am using Ubuntu inside Windows XP using VirtualBox, and I installed R properly. I am using a library called psych for this. The following is my code:
impact <- read.table("stats1.ex.02.txt", header=T)
class(impact)
describe(impact)
I am taking Statistics One course on coursera.org and the Prof gives this txt file to work with. When I run this in R, using source("test.R") (where test.R is the filename I gave),
nothing happens. What could be problem here ?
Try using source("test.R", echo=TRUE) or adding print to whatever you want printed after sourcing your script. Thus, your script might be:
impact<- read.table("stats1.ex.02.txt",header=T)
print(class(impact))
print(describe(impact))

Is there any way in Linux to show what's going on about the freezing code on the R session?

I am running a set of selected code on R. Like
source("/tmp/r-plugin-honli/Rsource-2704-quantmod.R")
There is no output. Only the prompt '>' flickered there.
I use 'killall' to kill the R session. But I don't know where is wrong on the code. Because R did not give any output. How could I know what's going on about the code.
I'd try two things:
Run the code interactively. As in, open the Rsource-2704 file and run its lines one by one.
If that doesn't replicate the problem or is not possible, you can take Joshua Ulrich's suggestion or use:
R CMD BATCH --vanilla Rsource-2704-quantmod.R out.log
Which will run the code in a batch mode and output the usual console lines to a file called out.log (you can name it whatever you like).
Instead of using print statements, you could also take a look at the browser() command. This drops you into an interactive session at the point where the command is put. This works particularly well when trying to figure out what is happening inside a function, although I don't know if your script contains them.

Resources