Hi R fans I am trying to make a program to ask the user to choose data file: print("Choose data file please !") matr=read.table(file.choose(),dec=".",header=TRUE) The problem is that the prompt Choose data file please ! comes after I have chosen the file. What am doing wrong? Thanks in advance Ralf Finne
Using print() for a 'prompt' is rather unusual: people normally use message() or cat(). You haven't told us your OS, but if this is Windows, see rw-FAQ Q7.1. On Sun, 29 Jul 2007, Ralf Finne wrote:> Hi R fans > > I am trying to make a program to ask the user to choose data file: > > print("Choose data file please !") > > matr=read.table(file.choose(),dec=".",header=TRUE) > > The problem is that the prompt > Choose data file please ! > comes after I have chosen the file. > > What am doing wrong? > > Thanks in advance > Ralf Finne > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >-- 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
You can use choose.files(caption="Choose data file please!",multi=FALSE,filters=Filters["All"]) This will show the prompt in the file selection dialog and also allows you to restrict the list of possible choises with a filter. Ralf Finne wrote:> > I am trying to make a program to ask the user to choose data file: > > print("Choose data file please !") > > matr=read.table(file.choose(),dec=".",header=TRUE) > > The problem is that the prompt > Choose data file please ! > comes after I have chosen the file. >-- View this message in context: http://www.nabble.com/Prompt-comes-too-late-tf4178913.html#a11919327 Sent from the R help mailing list archive at Nabble.com.
Maybe Matching Threads
- Reading Post-Script files
- Integrating R-programs into larger systems
- Question about assigning values in a matrix, conditional on column first row; how to do the loop.
- Error occurred during mean calculation of a column of a data frame, which is apparently contents numeric data
- Expert systems