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]]
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
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