# Running R from windows command prompt

9 messages
Open this post in threaded view
|

## Running R from windows command prompt

 1. I have a R program in a file say "functions.R". I load the "functions.R" file the R using source("function.R") and then call functionsf1(), f2() etc. which are declared and defined within "function.R"  file. I also need to load a couple of R libraries using library() before I can use f1(), f2() etc. My question is can I acheive all this (i.e. calling function f1() and f2()) from the windows prompt without opening the R environment ? If yes then how? 2. Also, Is there any way to scan strings directly. Like scan() function only scans numerical values. Is there any way to scan strings? -- Siddharth Arun, 4th Year Undergraduate student Industrial Engineering and Management, IIT Kharagpur         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Running R from windows command prompt

 On 28.06.2011 11:54, siddharth arun wrote: > 1. I have a R program in a file say "functions.R". > I load the "functions.R" file the R using source("function.R") and then call > functionsf1(), f2() etc. which are declared and defined within "function.R" >   file. > I also need to load a couple of R libraries using library() before I can > use f1(), f2() etc. > > My question is can I acheive all this (i.e. calling function f1() and f2()) > from the windows prompt without opening the R environment ? If yes then how? Put all the code into a file, e.g. "foo.R", and run R CMD BATCH foo.R from the windows command shell. > 2. Also, Is there any way to scan strings directly. Like scan() function > only scans numerical values. Is there any way to scan strings? Yes, it is called scan() which is for arbitrary data, including character(). See ?scan. Otherwise, you may want to look into ?readLines Uwe Ligges ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Running R from windows command prompt

 Thanks for your help. I tried the way you mentioned for my first question. But I am not getting any results. Can you please explain in detail the process through which I can run a R code from windows command prompt. 2011/6/28 Uwe Ligges <[hidden email]> > > > On 28.06.2011 11:54, siddharth arun wrote: > >> 1. I have a R program in a file say "functions.R". >> I load the "functions.R" file the R using source("function.R") and then >> call >> functionsf1(), f2() etc. which are declared and defined within >> "function.R" >>  file. >> I also need to load a couple of R libraries using library() before I can >> use f1(), f2() etc. >> >> My question is can I acheive all this (i.e. calling function f1() and >> f2()) >> from the windows prompt without opening the R environment ? If yes then >> how? >> > > > Put all the code into a file, e.g. "foo.R", and run > > R CMD BATCH foo.R from the windows command shell. > > > >  2. Also, Is there any way to scan strings directly. Like scan() function >> only scans numerical values. Is there any way to scan strings? >> > > Yes, it is called scan() which is for arbitrary data, including > character(). See ?scan. Otherwise, you may want to look into ?readLines > > Uwe Ligges > > -- Siddharth Arun, 4th Year Undergraduate student Industrial Engineering and Management, IIT Kharagpur         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Running R from windows command prompt

Open this post in threaded view
|

## Re: Running R from windows command prompt

Open this post in threaded view
|

## Re: Running R from windows command prompt

 In reply to this post by siddharth arun Hi Siddharth, many experts already answered your query, however I would like to share how I run R in command prompt: 1. open command prompt 2. change working directory: cd C:\................\R-2.13.0\bin\i386 (put the entire path here, however many people might find this step weird, you can have better management setting window's path variable appropriately) 3. type R.exe You can use R within command prompt with same efficiency. However most awkward thing I find in this process is you can never copy-paste any code. So everything you need to type there manually! HTH _____________________________________________________ Arun Kumar Saha, FRM QUANTITATIVE RISK AND HEDGE CONSULTING SPECIALIST Visit me at: http://in.linkedin.com/in/ArunFRM______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Running R from windows command prompt

 Subject: Re: [R] Running R from windows command prompt Hi Siddharth, many experts already answered your query, however I would like to share how I run R in command prompt: 1. open command prompt 2. change working directory: cd C:\................\R-2.13.0\bin\i386 (put the entire path here, however many people might find this step weird, you can have better management setting window's path variable appropriately) 3. type R.exe You can use R within command prompt with same efficiency. However most awkward thing I find in this process is you can never copy-paste any code. So everything you need to type there manually! ------------------- Actually, you can 'cut and paste' from at Windows Cmd prompt.  It is done by clicking the C: icon in the upper left of the command window, choosing edit, and 'copy' or 'paste' as desired. Rob HTH _____________________________________________________ Arun Kumar Saha, FRM QUANTITATIVE RISK AND HEDGE CONSULTING SPECIALIST Visit me at: http://in.linkedin.com/in/ArunFRM______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
{"extraction_info": {"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8567104935646057, "perplexity": 9806.499079420344}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-43/segments/1570987813307.73/warc/CC-MAIN-20191022081307-20191022104807-00293.warc.gz"}