On 13-May-09 19:49:35, Steve Sidney wrote:
> Dear list
> I have managed to write a short program to evaluate data which is
> inputted from a csv file using the following
> 
> x = read.csv("wms_results.csv", header=TRUE)
> 
> All works fine but since I have a number of similar data files which
> have different names, I would like the program to allow me to input
> the file name, rather than having to edit the program.
> 
> From the documentation I am unclear how to replace the "filename.csv"
> with a string varaiable so that from the keyboard I can input the name.
> 
> Also which command can I use to output some text to the monitor as a
> prompt
> 
> Any help would be great and apologies for such a simple question.
> Thanks
> 
> Regards
> Steve

Try:

  NextFile <- readline("Enter the CSV filename:\n")
  x = read.csv(NextFile, header=TRUE)

You will then get a prompt "Enter the CSV filename:"
so enter it. Then it will read it.

Example (from the terminal):

  > NextFile <- readline("Enter the CSV filename:\n")
  Enter the CSV filename:
  ACBDEFG.csv
  > NextFile
  [1] "ACBDEFG.csv"
  >

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 13-May-09                                       Time: 21:12:19
------------------------------ XFMail ------------------------------

______________________________________________
R-help@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.

Reply via email to