[R-SIG-Finance] problem with import data

G See gsee000 at gmail.com
Sun Apr 29 15:20:45 CEST 2012


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 at 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 at 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.



More information about the R-SIG-Finance mailing list