[R] for importing "data"

Roger Bivand Roger.Bivand at nhh.no
Mon Oct 30 10:08:18 CET 2006


On Mon, 30 Oct 2006, amna khan wrote:

> *I am a very new user of R. I've spent several hours trying to import
> data, so I feel okay asking the list for help. *
> *I had an Excel file,  then I turned it into a "tab-delimited" file, as
> instructed by directions My
> filename is "lahore.txt" I amusing the following commands for read.delim but
> i am getting following mesages. Sir i am sending you my excel data file i
> request you to   please write the right read.delim function for  importing
> data file after transforming it into a tab-delimited form.*
> 
> lahore<-read.delim("lahore.txt")
> Error in file(file, "r") : unable to open connection
> In addition: Warning message:
> cannot open file 'lahore.txt', reason 'No such file or directory'

I am sure that your experience is familiar to many of us, especially those 
using R with beginners. 

>From the error messages, you can see that the file is not present where R 
is looking for it. R is looking in your working directory - use getwd() to 
see what that is. setwd() will let you move to the correct directory - 
please use "/" as the separator on the directory path.

The function list.files() will show the files in the directory. If you are
using Windows, it is further likely that the file is not actually called
what you named it (Windows can add extra .* extensions which you do not
see unless you have told Windows Explorer to show them).

On Windows, you can use file.choose() to find the file visually, but it is 
usually better to learn the direct methods, because they are recorded in 
your session history, which you can save as documentation of your work - 
something that is extremely useful if you return to a project after some 
days, and (like me) cannot remember what you clicked.

Hope this helps,

Roger

> 
> Regards
> 
> AMINA SHAHZADI*.*
> Department of Statistics
> GC University Lahore, Pakistan.
> Email:
> amnakhan493 at gmail.com
> amna_989 at hotmail.com
> amna_989 at yahoo.com
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-help mailing list