我有2個csv數據文件。 1分鐘的酒吧和5分鐘的酒吧。 這兩個文件都是相同的格式。2 csv文件返回不同的數據類型
文件1是
> 2007-01-02 10:00:00.000,NIFTY,ABB,2007-01-02 10:00:00.000,750.4,750.4,750,750.2
2007-01-02 10:01:00.000,NIFTY,ABB,2007-01-02 10:01:00.000,750.38,750.4,749.8,749.8
2007-01-02 10:02:00.000,NIFTY,ABB,2007-01-02 10:02:00.000,749.8,750,749.6,750
2007-01-02 10:03:00.000,NIFTY,ABB,2007-01-02 10:03:00.000,749.6,752.4,749.6,752
2007-01-02 10:04:00.000,NIFTY,ABB,2007-01-02 10:04:00.000,752,755.8,752,754.2
2007-01-02 10:05:00.000,NIFTY,ABB,2007-01-02 10:05:00.000,754.02,755,752.05,753.6
2007-01-02 10:06:00.000,NIFTY,ABB,2007-01-02 10:06:00.000,753,753,751,751
2007-01-02 10:07:00.000,NIFTY,ABB,2007-01-02 10:07:00.000,751,751.62,750.5,751
2007-01-02 10:08:00.000,NIFTY,ABB,2007-01-02 10:08:00.000,750.8,751,750.2,750.62
文件2是
> 2007-01-02 10:00:00.000,NIFTY,ABB,2007-01-02 10:00:00.000,750.2,754.2,749.8,753.6
2007-01-02 10:05:00.000,NIFTY,ABB,2007-01-02 10:05:00.000,753.6,753.6,750.62,752.8
2007-01-02 10:10:00.000,NIFTY,ABB,2007-01-02 10:10:00.000,752.8,752.8,750.2,751.5
2007-01-02 10:15:00.000,NIFTY,ABB,2007-01-02 10:15:00.000,751.5,752,751,751.6
2007-01-02 10:20:00.000,NIFTY,ABB,2007-01-02 10:20:00.000,751.6,751.6,750.8,751
2007-01-02 10:25:00.000,NIFTY,ABB,2007-01-02 10:25:00.000,751,751.2,749,749
2007-01-02 10:30:00.000,NIFTY,ABB,2007-01-02 10:30:00.000,749,751.8,749,751.8
2007-01-02 10:35:00.000,NIFTY,ABB,2007-01-02 10:35:00.000,751.8,752,751.1,751.4
現在我運行 一個< - read.csv( 「file1.csv」)
類(A [ (a [,5:8])是數字
而在文件的情況下,2
b < - read.csv( 「file2.csv」)
類(B [1:4])是因子
類(B [ ,5:8])是因素。
怎麼樣的列5:8是因素。這種因素類型的數據不會讓我繼續我的分析。任何想法。
單獨的數據是否會發生問題,還是有額外的行?也許第二個文件中有一行包含字符串?我相信R會強制將行中的所有內容強制轉換爲字符串,並且默認情況下會將字符串轉換爲因子。 (請參閱'stringsAsFactors'參數以'read.table'。) – Mars 2013-04-07 04:23:14