[R] for importing data

2006-10-30 Thread amna khan
*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'

Regards

AMINA SHAHZADI*.*
Department of Statistics
GC University Lahore, Pakistan.
Email:
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

[[alternative HTML version deleted]]

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


Re: [R] for importing data

2006-10-30 Thread Gabor Grothendieck
Move to the appropriate directory first (or else move your
file to where you are now).  For example,
1. if the file is in \ then

   setwd(/)

2. or

   getwd()

which shows where you are now and then you can move your
file to that spot.

3. Another possibility is:

   read.delim(file.choose())

which will bring up a file explorer window so you can traverse the file
system to find it.

On 10/30/06, amna khan [EMAIL PROTECTED] 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'

 Regards

 AMINA SHAHZADI*.*
 Department of Statistics
 GC University Lahore, Pakistan.
 Email:
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]

[[alternative HTML version deleted]]

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


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


Re: [R] for importing data

2006-10-30 Thread David Barron
Most likely the file lahore.txt isn't in the current working
directory, which is where R will be looking for it as you don't
specify a path (I'm assuming that you are working in Windows).  If so,
you have three options.  1) Move lahore.txt to the current working
directory (you can find with directory that is using the function
getwd()).  2) Specify the full path in read.delim (e.g.,
read.delim(c:/my documents/data/lahore.txt).  3) Change the working
directory to the one in which lahore.txt is located using the function
setwd().

Hope this helps.
David

On 30/10/06, amna khan [EMAIL PROTECTED] 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'

 Regards

 AMINA SHAHZADI*.*
 Department of Statistics
 GC University Lahore, Pakistan.
 Email:
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]

 [[alternative HTML version deleted]]

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



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

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


Re: [R] for importing data

2006-10-30 Thread Roger Bivand
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:
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 
   [[alternative HTML version deleted]]
 
 __
 R-help@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: [EMAIL PROTECTED]

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


Re: [R] for importing data

2006-10-30 Thread Hans-Peter
Hi,

 *I had an Excel file,  then I turned it into a tab-delimited file, as
 ...
 lahore-read.delim(lahore.txt)

I suppose you are on windows, hence you can use the package
xlsReadWrite to read the Excelfile directly. It's on the CRAN and you
can download it from the RGui under the menu: Packages -  Install
package(s)... (select a mirror, download).

Example: lahore - read.xls( lahore.xls )

Gives back the data from the first sheet as a data.frame and assumes
that there is a header row. Without header row set the colNames
argument to FALSE.

This is a user contributed package and doesn't belong to the core R
environment, hence you shouldn't post in this group if need help with
it (contact me or much better go to:
http://groups.google.ch/group/supportR). xlsReadWrite is a bit
non-standard and currently non-portable. So maybe not appropriate for
a novice. On the other hand it is easy to use and no need for csv
detours to get your data...

 Error in file(file, r) : unable to open connection
 In addition: Warning message:
 cannot open file 'lahore.txt', reason 'No such file or directory'

Already answered: ?getwd  ?setwd

-- 
Regards,
Hans-Peter

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