0

Leaving question for archival purposes only. (Read.csv did read in all columns, I just did not see them in the preview when opening the data.frame)

Related to this question: Maximum number of columns that can be read using read.csv I would like to import a csv file into R that contains about 3200 columns (100 rows). I am used to working with data.frames and read.csv, but my usual approach failed because

data <- read.csv("data.csv", header=TRUE)

only imported the first 2105 columns. It did not display an error message.

  • How can I readin a csv file with more than 2105 columns?
    • without specifying column classes
    • into a data frame
    • the file contains different data types (dates, strings, numbers, ..)
    • speed is not my biggest concern

I did not manage to apply the solutions in Quickly reading very large tables as dataframes in R to my situation. Tried this, but it does not seem to work without information on column classes:

df <- as.data.frame(scan("data.csv",sep=','))

There are already several questions about reading in large datafiles with millions of rows/columns and how to speed up the process, but my files are much smaller, so I am hoping that there is an easier solution that I overlooked.

Community
  • 1
  • 1
Kastany
  • 427
  • 1
  • 5
  • 16

2 Answers2

2

Try using data.table.

library(data.table)

data <- fread("data.csv")
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
  • Thank you for your response. I am going to close this question because I made a stupid mistake when posting. read.csv actually did import all columns, I just did not see them in the data.frame preview. – Kastany May 03 '16 at 10:08
  • No problem. In any case, I recommend you stick to `fread{data.table}` because it is by far the fastest way of reading `.csv` files into R. – rafa.pereira May 03 '16 at 10:16
0

(Posted answer on behalf of the OP).

Read.csv did read in all columns, I just did not see them in the preview when opening the data.frame

halfer
  • 19,824
  • 17
  • 99
  • 186