Previous: Why can't I install | Up: For All Zelig Users | Next: Where can I find |
When you start R, you need to specify your working directory. In linux R, this is done pretty much automatically when you start R, whether within ESS or in a terminal window. In Windows R, you may wish to specify a working directory so that you may load data without typing in long directory paths to your data files, and it is important to remember that Windows R uses the Linux directory delimiter. That is, if you right click and select the ``Properties'' link on a Windows file, the slashes are backslashes ( 1#1 ), but Windows R uses forward slashes (/) in directory paths. Thus, the Windows link may be C: 1#1 Program Files 1#1 R 1#1 R-2.5.1 1#1 , but you would type C:/Program Files/R/R-2.5.1/ in Windows R.
When you start R in Windows, the working directory is by default the directory in which the R executible is located.
# Print your current working directory. > getwd() # To read data not located in your working directory. > data <- read.table("C:/Program Files/R/newwork/mydata.tab") # To change your working directory. > setwd("C:/Program Files/R/newwork") # Reading data in your working directory. > data <- read.data("mydata.tab")Once you have set the working directory, you no longer need to type the entire directory path.