Thanks for this and thanks also to Brian.

One thing,I've now imported the data using the following instructions as G
See suggested

c1<-read.table("t1.txt",header=TRUE,sep="\t")

When I write

c1[2]

on the console I get the following output

1  345
2  344
3  678
...
...
6703 567


(So 6703 data points, the first data point being 345, the last being 567)


But if I call the following

plot(c1[2])

I just get a flat horizontal line.


While I know using quantmod this problem goes away, but if I have to import
data from a csv/txt file, I want to know how to deal with this issue.


On Sun, Apr 29, 2012 at 2:20 PM, G See <gsee000@gmail.com> wrote:

> Krisan,
>
> As Brian mentioned, quantmod would make things easier for you, but to
> answer your immediate question..
>
> If it really is tab delimited, you could try
>    read.table("t1.txt", header=TRUE, sep="\t")
>
> If it's a CSV, then try
>    read.table("t1.txt", header=TRUE, sep=",")
>    # or
>    read.csv("t1.txt")
>
> For more, check this section of the R Data Import/Export manual:
> http://cran.r-project.org/doc/manuals/R-data.html#Spreadsheet_002dlike-data
>
> HTH,
> Garrett
>
> On Sun, Apr 29, 2012 at 4:48 AM, krisan haria <krisanharia@gmail.com>
> wrote:
> >>
> >> Hi,
> >>
> >> Im trying to import data from yahoo into R. I downloaded the data from
> >> yahoo into a csv file and then saved the csv file into a txt file (tab
> >> delimited).
> >>
> >> From R I then call the function
> >>
> >> read.table("t1.txt")
> >>
> >> but I get the following error
> >>
> >> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
> >> na.strings,  :
> >>   line 2 did not have 8 elements
> >>
> >> I tried
> >>
> >> read.table("t1.txt", header=T)
> >>
> >> but same error
> >>
> >> I suspect this is linked to the fact I seem to be importing an extra
> >> column but I have no idea on how to get rid of this extra column.
> >>
> >> My R version is R 2.13.1
> >>
> >> Any ideas?
> >>
> >> Regards
> >>
> >> Krisan
> >>
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-SIG-Finance@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions
> should go.
>

	[[alternative HTML version deleted]]

