[英]read.table and read.csv skip the first column?
I have a file likes below:我有一个喜欢下面的文件:
> pageid,revid,user_rating
>
> 1073624,16845228,Start
...
and I use:我使用:
data = read.csv (file_name)
then:然后:
str(data)
then I have:然后我有:
$ pageid : int 16845228
...
The pageid should start with '1073624', not '16845228'. pageid 应该以“1073624”开头,而不是“16845228”。
Also, I have the same file content, just instead of ',' is 'tab' character.另外,我有相同的文件内容,只是代替 ',' 是 'tab' 字符。
> pageid revid user_rating
>
> 1073624 16845228 Start
and I use:我使用:
data = read.table (file_name, header = TRUE, sep = '\t')
And when I showed data, I have the same problem.当我显示数据时,我遇到了同样的问题。
What did I do wrong?我做错了什么?
Thank you very much for your answers.非常感谢您的回答。 However I found the problem: there is a ',' redundant in the end of each line, so R misunderstood the data.
但是我发现了问题:每行末尾都有一个 ',' 多余的,所以 R 误解了数据。 Remove this character and everything is okay.
删除此字符,一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.