help with read.table() function

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

help with read.table() function

oliver wee
hello, I have just started using R for doing a project
in time series...

unfortunately, I am having trouble using the
read.table function for use in reading my data set.

This is what I'm getting:
I inputted:
data <-
read.table("D:/Oliver/Professional/Studies/Time Series
Analysis/spdc2693.data", header = TRUE)

I got:
Error in file(file, "r") : unable to open connection
In addition: Warning message:
cannot open file 'D:/Oliver/Professional/Studies/Time
Series Analysis/spdc2693.data', reason 'No such file
or directory'

as I am just a novice programmer, I really would
appreciate help from you guys. Is there a need to
setpath in R, like in java or something like that...

I am using the windows version btw.

I have also tried to put the file in the work
directory of R, so that I only typed
data <- read.table("spdc2693.data", header = TRUE)
Again, it won't work, with the same error message.

I would appreciate any help. thanks again.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: help with read.table() function

Romain François
Le 29.01.2006 16:26, oliver wee a écrit :

>hello, I have just started using R for doing a project
>in time series...
>
>unfortunately, I am having trouble using the
>read.table function for use in reading my data set.
>
>This is what I'm getting:
>I inputted:
>data <-
>read.table("D:/Oliver/Professional/Studies/Time Series
>Analysis/spdc2693.data", header = TRUE)
>
>I got:
>Error in file(file, "r") : unable to open connection
>In addition: Warning message:
>cannot open file 'D:/Oliver/Professional/Studies/Time
>Series Analysis/spdc2693.data', reason 'No such file
>or directory'
>
>as I am just a novice programmer, I really would
>appreciate help from you guys. Is there a need to
>setpath in R, like in java or something like that...
>
>I am using the windows version btw.
>
>I have also tried to put the file in the work
>directory of R, so that I only typed
>data <- read.table("spdc2693.data", header = TRUE)
>Again, it won't work, with the same error message.
>
>I would appreciate any help. thanks again.
>  
>
Hi, try :

read.table(file.choose(), header=TRUE)

and go to your file.
Also, you can look a ?setwd, ?getwd

Romain

--
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
mixmod 1.7 is released : http://www-math.univ-fcomte.fr/mixmod/index.php
+---------------------------------------------------------------+
| Romain FRANCOIS - http://francoisromain.free.fr               |
| Doctorant INRIA Futurs / EDF                                  |
+---------------------------------------------------------------+

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: help with read.table() function

Peter Dalgaard
Romain Francois <[hidden email]> writes:

> Le 29.01.2006 16:26, oliver wee a écrit :
>
> >hello, I have just started using R for doing a project
> >in time series...
> >
> >unfortunately, I am having trouble using the
> >read.table function for use in reading my data set.
> >
> >This is what I'm getting:
> >I inputted:
> >data <-
> >read.table("D:/Oliver/Professional/Studies/Time Series
> >Analysis/spdc2693.data", header = TRUE)
> >
> >I got:
> >Error in file(file, "r") : unable to open connection
> >In addition: Warning message:
> >cannot open file 'D:/Oliver/Professional/Studies/Time
> >Series Analysis/spdc2693.data', reason 'No such file
> >or directory'
> >
> >as I am just a novice programmer, I really would
> >appreciate help from you guys. Is there a need to
> >setpath in R, like in java or something like that...
> >
> >I am using the windows version btw.
> >
> >I have also tried to put the file in the work
> >directory of R, so that I only typed
> >data <- read.table("spdc2693.data", header = TRUE)
> >Again, it won't work, with the same error message.
> >
> >I would appreciate any help. thanks again.
> >  
> >
> Hi, try :
>
> read.table(file.choose(), header=TRUE)
>
> and go to your file.
> Also, you can look a ?setwd, ?getwd

Right. Or just file.choose() and see what the OS thinks your file is
really called. The most common causes for symptoms like that are

(A) The file is "spcd2693.data"
(B) There's an extra extension which ever helpful Windows decided to
hide, as in "spdc2693.data.txt".


--
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([hidden email])                  FAX: (+45) 35327907

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: help with read.table() function

Duncan Murdoch
In reply to this post by oliver wee
On 1/29/2006 11:28 AM, oliver wee wrote:

> hi,
>
> Sorry again to bother you, but I got the file.choose()
> to work. Thanks for the help there.
>
> Unfortunately I encountered a new problem. After I
> selected the data, I got this error message:
>
> Error in scan(file = file, what = what, sep = sep,
> quote = quote, dec = dec,  :
>         line 1 did not have 11 elements
> In addition: Warning message:
> incomplete final line found by readTableHeader on
> 'D:\Oliver\Professional\Studies\Time Series
> Analysis\spdc2693.data.txt'
>
> my time series data looks like this...
>
> ------------
> Standard and Poor's 500 Index closing values from 1926
> to 1993.
>
>   Date       Index
>   260101     12.76
>   260108     12.78
>   260115     12.52
>   260122     12.45
>   260129     12.74
>   260205     12.87
>   260212     12.87
>   260219     12.74
>   260226     12.18
>   260305     11.99
>   260312     12.15
>   260319     11.64
>   260326     11.46
> ...
> (and so on)
> ----------
>
> Should I insert additional attributes besides header =
> TRUE?

Yes, you need to tell it to skip over the lines of the comment at the
start of the file.  That looks like 3 lines (including the blank line),
so add skip=3 to your read.table call.

Duncan Murdoch

> thanks.
>
>
> --- Duncan Murdoch <[hidden email]> wrote:
>
>> On 1/29/2006 10:26 AM, oliver wee wrote:
>>> hello, I have just started using R for doing a
>> project
>>> in time series...
>>>
>>> unfortunately, I am having trouble using the
>>> read.table function for use in reading my data
>> set.
>>> This is what I'm getting:
>>> I inputted:
>>> data <-
>>> read.table("D:/Oliver/Professional/Studies/Time
>> Series
>>> Analysis/spdc2693.data", header = TRUE)
>> Generally it's easier to use the dialogs to specify
>> the filename, e.g.
>>
>> read.table(file.choose(), header=TRUE)
>>
>> Then you shouldn't get the "no such file" message.
>> If you do, you
>> should check whether other programs (e.g. notepad)
>> can open the file.
>> Maybe you don't have read permission?
>>
>> Duncan Murdoch
>>
>>> I got:
>>> Error in file(file, "r") : unable to open
>> connection
>>> In addition: Warning message:
>>> cannot open file
>> 'D:/Oliver/Professional/Studies/Time
>>> Series Analysis/spdc2693.data', reason 'No such
>> file
>>> or directory'
>>>
>>> as I am just a novice programmer, I really would
>>> appreciate help from you guys. Is there a need to
>>> setpath in R, like in java or something like
>> that...
>>> I am using the windows version btw.
>>>
>>> I have also tried to put the file in the work
>>> directory of R, so that I only typed
>>> data <- read.table("spdc2693.data", header = TRUE)
>>> Again, it won't work, with the same error message.
>>>
>>> I would appreciate any help. thanks again.
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide!
>> http://www.R-project.org/posting-guide.html
>>
>>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: help with read.table() function

Gabor Grothendieck
Normally one expects stdin to be the default on command line
programs and something like file.choose to be the default on GUI
programs and this would break that expectation.

If there were a GUI version of read.table then that would reasonbly
have file.choose as the default.

On 1/29/06, Duncan Murdoch <[hidden email]> wrote:

> On 1/29/2006 11:28 AM, oliver wee wrote:
> > hi,
> >
> > Sorry again to bother you, but I got the file.choose()
> > to work. Thanks for the help there.
> >
> > Unfortunately I encountered a new problem. After I
> > selected the data, I got this error message:
> >
> > Error in scan(file = file, what = what, sep = sep,
> > quote = quote, dec = dec,  :
> >         line 1 did not have 11 elements
> > In addition: Warning message:
> > incomplete final line found by readTableHeader on
> > 'D:\Oliver\Professional\Studies\Time Series
> > Analysis\spdc2693.data.txt'
> >
> > my time series data looks like this...
> >
> > ------------
> > Standard and Poor's 500 Index closing values from 1926
> > to 1993.
> >
> >   Date       Index
> >   260101     12.76
> >   260108     12.78
> >   260115     12.52
> >   260122     12.45
> >   260129     12.74
> >   260205     12.87
> >   260212     12.87
> >   260219     12.74
> >   260226     12.18
> >   260305     11.99
> >   260312     12.15
> >   260319     11.64
> >   260326     11.46
> > ...
> > (and so on)
> > ----------
> >
> > Should I insert additional attributes besides header =
> > TRUE?
>
> Yes, you need to tell it to skip over the lines of the comment at the
> start of the file.  That looks like 3 lines (including the blank line),
> so add skip=3 to your read.table call.
>
> Duncan Murdoch
>
> > thanks.
> >
> >
> > --- Duncan Murdoch <[hidden email]> wrote:
> >
> >> On 1/29/2006 10:26 AM, oliver wee wrote:
> >>> hello, I have just started using R for doing a
> >> project
> >>> in time series...
> >>>
> >>> unfortunately, I am having trouble using the
> >>> read.table function for use in reading my data
> >> set.
> >>> This is what I'm getting:
> >>> I inputted:
> >>> data <-
> >>> read.table("D:/Oliver/Professional/Studies/Time
> >> Series
> >>> Analysis/spdc2693.data", header = TRUE)
> >> Generally it's easier to use the dialogs to specify
> >> the filename, e.g.
> >>
> >> read.table(file.choose(), header=TRUE)
> >>
> >> Then you shouldn't get the "no such file" message.
> >> If you do, you
> >> should check whether other programs (e.g. notepad)
> >> can open the file.
> >> Maybe you don't have read permission?
> >>
> >> Duncan Murdoch
> >>
> >>> I got:
> >>> Error in file(file, "r") : unable to open
> >> connection
> >>> In addition: Warning message:
> >>> cannot open file
> >> 'D:/Oliver/Professional/Studies/Time
> >>> Series Analysis/spdc2693.data', reason 'No such
> >> file
> >>> or directory'
> >>>
> >>> as I am just a novice programmer, I really would
> >>> appreciate help from you guys. Is there a need to
> >>> setpath in R, like in java or something like
> >> that...
> >>> I am using the windows version btw.
> >>>
> >>> I have also tried to put the file in the work
> >>> directory of R, so that I only typed
> >>> data <- read.table("spdc2693.data", header = TRUE)
> >>> Again, it won't work, with the same error message.
> >>>
> >>> I would appreciate any help. thanks again.
> >>>
> >>> ______________________________________________
> >>> [hidden email] mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide!
> >> http://www.R-project.org/posting-guide.html
> >>
> >>
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html