我是R新手,想讀取csv文件。但是,當我嘗試閱讀時遇到錯誤。 我的csv文件如下:從R讀取csv文件
,Zbot,Sirefef,Fareit,Winwebsec,FakeSysdef,Winwebsec,Winwebsec,Winwebsec,Fareit,Fareit,Sirefef,Winwebsec,Winwebsec,Winwebsec,Winwebsec
Zbot,0,134,45,651,182,245,986,64,63,34,134,166,52,337,225
Sirefef,142,0,124,679,200,273,1018,156,125,122,164,198,120,371,257
Fareit,48,124,0,644,166,234,978,82,64,51,135,167,49,338,224
Winwebsec,651,499,470,0,575,556,1087,525,490,485,501,511,483,600,582
FakeSysdef,178,172,143,535,0,311,1052,196,163,152,204,234,154,405,285
Winwebsec,245,199,168,478,229,0,997,217,186,183,199,209,183,348,272
Winwebsec,986,752,719,821,784,727,0,774,739,734,750,760,734,851,829
Winwebsec,80,160,85,506,179,204,757,0,100,85,173,205,89,376,264
Fareit,65,95,32,468,141,164,715,78,0,57,135,165,59,336,226
Fareit,52,122,51,468,143,166,717,68,40,0,135,163,49,336,224
Sirefef,136,118,85,449,150,147,696,123,83,83,0,146,100,317,207
Winwebsec,164,138,105,449,170,145,696,143,103,103,80,0,118,315,215
Winwebsec,52,116,51,466,143,166,717,66,42,32,83,103,0,336,226
Winwebsec,335,267,234,496,301,246,745,272,232,234,213,213,234,0,346
Winwebsec,225,204,171,519,228,217,774,207,169,169,150,160,169,291,0
當我在RStudio使用此命令我得到錯誤: 命令:
> tb = read.csv("/home/hossein/Documents/LiClipse Workspace/test.csv", row.names = 1);
錯誤:
錯誤函數read.table中(文件= file,header = header,sep = sep,quote = quote,: 重複'row.names'不允許
我也試着去掉e的錯誤,並使用此命令:
> tb = read.csv("/home/hossein/Documents/LiClipse Workspace/test.csv", row.names = NULL);
但是,當我查看輸出是它不能保持方陣的結構。你能幫我,我該怎麼辦?
首先,數據集的第一行以逗號開頭。其次,爲什麼不嘗試使用RStudio加載數據集的GUI功能?如果你這樣做,你可能會有更好的機會來檢測你的數據加載不正確的原因。 – Abdou