Banjo
Banjo

Reputation: 1251

R doesn´t read all lines of a csv

I have an excel file and I want to read it in R. To do this I converted the file into a csv. Overall, the file contains 17.000 rows and 27 columns.

This is the code I used:

read.csv("example.csv", sep = ";", stringsAsFactors = F, quote = "", header = T, fill = T)

However, R only reads 27 rows. I read some post on this topic. So I used quote = "" to fix this issue (see the code above).

For this task I used RStudio. If I disable quote I get the message line 14 have not 27 elements (the file has 27 columns). Maybe it has something to with this.

Upvotes: 0

Views: 1172

Answers (2)

JBGruber
JBGruber

Reputation: 12478

There should be no need to convert your excel file. Simply:

install.packages("rio")
rio::import("example.xlsx")

*(rio is just a wrapper for different import/export packages/functions but the default values worked in 99% of my cases so far.)

Upvotes: 2

moon_coder
moon_coder

Reputation: 94

You can try in-built facility for importing or reading file in R Studio which is in left topmost corner of the GUI. Hope it may helps you.

Upvotes: 0

Related Questions