R trouble reading my files with read.csv

对着背影说爱祢 提交于 2020-01-07 03:14:29

问题


I'm currently trying to read two .csv files, edit the data, and then write it into a new .csv.

here the code :

data <- read.csv("file.csv"), fill=TRUE, header=TRUE, row.names=NULL, stringAsFactors=FALSE, sep=",", quote="")
write.csv(data, file="out.csv")

Here's the problem : Everything is fine with the first file (20 columns, 572 observations)

However, the other file has 163 columns and 1578 lines but when I read it with read.csv, R displays "2301 observations of 163 variables".

I tried to write this dataframe into a new csv file, and it is a total mess :

  1. the rows have not been written entirely, the last values are written on a new row
  2. there is a new column with integers from 1 to 2301
  3. some data which is supposed to be in file$n is written in file$(n-1) or file$(n-2)

I'm a newbie, and I must admit I'm kind of lost : any help would be highly appreciated!

Thanks

Clément

来源:https://stackoverflow.com/questions/24629442/r-trouble-reading-my-files-with-read-csv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!