When I use the scan function in the Rgui console it works as expected. However it seems that when I put the same command in a script file it doesn't wait for input. Is there an option to scan to make it wait for input when used in a script? Or is there possibly a different function that will do in a script the same sort of thing as scan does in the console? Thanks, Mark
Exactly how are you using it? How you executing your script? Are you using cut/paste or source? Have you tried 'readline'? More details on what you mean by it does not work as expected. On Thu, Jul 9, 2009 at 2:24 PM, Mark Knecht<markknecht at gmail.com> wrote:> When I use the scan function in the Rgui console it works as expected. > However it seems that when I put the same command in a script file it > doesn't wait for input. > > Is there an option to scan to make it wait for input when used in a > script? Or is there possibly a different function that will do in a > script the same sort of thing as scan does in the console? > > Thanks, > Mark > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
Check out: http://tolstoy.newcastle.edu.au/R/help/03a/6855.html On Thu, Jul 9, 2009 at 2:24 PM, Mark Knecht<markknecht at gmail.com> wrote:> When I use the scan function in the Rgui console it works as expected. > However it seems that when I put the same command in a script file it > doesn't wait for input. > > Is there an option to scan to make it wait for input when used in a > script? Or is there possibly a different function that will do in a > script the same sort of thing as scan does in the console? > > Thanks, > Mark > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
It looks like you are trying to use the scan function to pause some script being called with the source function until you provide user input. To do this, you need to specify the argument file="stdin" when scan runs inside a process. EG scan(file='stdin', nmax=1). In my Linux terminal, at least, (using 2.15) I lose the prompt (which formerly defaulted to '1:') and have to enter some arbitrary value like '1' (whereas hitting enter with no value entered counted as input when running from an interactive session). -- View this message in context: http://r.789695.n4.nabble.com/scan-in-a-script-tp898837p4649634.html Sent from the R help mailing list archive at Nabble.com.