0

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.

Banjo
  • 1,191
  • 1
  • 11
  • 28
  • Possible duplicate of [How can you read a CSV file in R with different number of columns](https://stackoverflow.com/questions/18922493/how-can-you-read-a-csv-file-in-r-with-different-number-of-columns) – Wimpel Feb 03 '19 at 14:15
  • I tried the code of this post `read.table("example.csv", header = FALSE, sep = ";", col.names = paste0("V",seq_len(27)), fill = TRUE)` However, this doesn´t work also. – Banjo Feb 03 '19 at 14:21
  • Give `readr::read_csv` a try (with no arguments). If this doesn't work, try playing around with arguments like `check.names = TRUE` (see `?read_csv`). – Marian Minar Feb 03 '19 at 14:55

2 Answers2

2

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.)

JBGruber
  • 11,727
  • 1
  • 23
  • 45
0

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.

moon_coder
  • 84
  • 1
  • 9