[R] Running rscript in windows

Peter Ehlers ehlers at ucalgary.ca
Thu Feb 11 09:02:53 CET 2010

How did you change directory? Does dir() show that your
directory is the desktop? Presumably the desktop folder
is something like C:/Users/<someone>/Desktop. Sourcing
test.R from there should work. But the simplest way is


and then navigate to where test.R is located.

  -Peter Ehlers

vikrant wrote:
> Hi,
> I saved the function in test.R file on Desktop. Then after starting R I
> changed my directory to desktop.
> and tried the command source("test.R") it gave me following error
> Error in file(file, "r", encoding = encoding) : 
>   cannot open the connection
> In addition: Warning message:
> In file(file, "r", encoding = encoding) :
>   cannot open file 'test.R': No such file or directory

Peter Ehlers
University of Calgary

More information about the R-help mailing list