[R] problem with "choose.files" command & interactive functions

From: Shay O'Farrell <S.Ofarrell_at_exeter.ac.uk>
Date: Thu, 26 Mar 2009 13:09:17 +0000


Hi all,

Iím new to R, and Iím having a small but annoying problem with the choose.files command, using version 2.8.1 in Windows XP. I am holding my data text files in C:\\Data\\, and Iím writing a short script that first resets the default directory to this directory, then allows me to interactively select which text file to import and attach, using the Windows widget. Here is my script:

setwd("C:\\Data\\")
data<-read.table(choose.files(),header=T,as.is=T) attach(data)

If I copy and paste the script into R Editor (or directly into RGui) and run it, it works perfectly. However, if have imported the script using the Open Script button in RGui, then I have a glitch... when I run the script, the widget looks in the last folder that I opened interactively (i.e., the folder from which I imported my script file) instead of looking in the new working directory. BUT... if I run line 3 again straight after, it works perfectly the second time. What am I doing wrong? Any help would be appreciated.

Thanks

Shay



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. Received on Thu 26 Mar 2009 - 12:14:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 26 Mar 2009 - 13:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive