[R] cat not evaluated before file.choose
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sun Nov 26 11:44:55 CET 2006
I believe this is specific to the MacOS (and Windows) GUI, which you did
not mention you were using.
See ?flush.console for the solution. Your subject line is misleading: it
is the console that is delaying showing the result.
On Sat, 25 Nov 2006, Kevin Middleton wrote:
> As part of a larger function I have code similar to the reduced
> example below. The user is instructed to choose a file, which gets
> read using read.csv. In this example, I just have the name of the
> file print out.
>
> When I call this function with choosefile(), the file dialog box
> appears before the first cat line is printed. After I choose a file,
> both cat lines are printed.
>
> choosefile <- function (){
> cat("Choose the data file.\n")
> filename <- file.choose(new = FALSE)
> cat("You chose: ", filename, sep = "")
> }
>
> Is there a way to force the first cat line to print before the call
> to file.choose? I'm using R 2.4.0 Patched (2006-11-24 r39989) on OS
> X. Session info below.
>
> Any suggestions would be greatly appreciated.
>
> Kevin Middleton
>
> -------
>
> > sessionInfo()
> R version 2.4.0 Patched (2006-11-24 r39989)
> powerpc-apple-darwin8.8.0
>
> locale:
> en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] "stats" "graphics" "grDevices" "utils" "datasets"
> "methods" "base"
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list