Questions tagged [read.csv]

The command in R to read a data file with a “comma separated values” (csv) format.

The read.csv is a command in R to read a data file with a “comma separated values” (csv) format.

462 questions
19
votes
3 answers

read.csv vs. read.table

I have seen in several cases that while read.table() is not able to read a tab delimited file (for example the annotation table of a microarray) returning the following error: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,…
Ali
  • 8,590
  • 11
  • 55
  • 86
16
votes
4 answers

read.csv row.names

I'm trying to read a column oriented csv file into R as a data frame. the first line of the file is like so: sDATE, sTIME,iGPS_ALT, ... and then each additional line is a measurement: 4/10/2011,2:15,78, ... when I try to read this into R, via d =…
nimish
  • 4,110
  • 3
  • 18
  • 33
14
votes
3 answers

Read csv with dates and numbers

I have a problem when I import a csv file with R: example lines to import: 2010-07-27;91 2010-07-26;93 2010-07-23;88 I use the statement: data <- read.csv2(file="...", sep=";", dec=".", header=FALSE) when I try to aggregate this data with other…
keanu
  • 141
  • 1
  • 1
  • 3
13
votes
1 answer

read.csv() with UTF-8 encoding

I am trying to read in data from a csv file and specify the encoding of the characters to be UTF-8. From reading through the ?read.csv() instructions, it seems that fileEncoding set equal to UTF-8 should accomplish this, however, I am not seeing…
Rob.C
  • 199
  • 1
  • 1
  • 8
11
votes
5 answers

Read csv file in R with currency column as numeric

I'm trying to read into R a csv file that contains information on political contributions. From what I understand, the columns by default are imported as factors, but I need the the amount column ('CTRIB_AMT' in the dataset) to be imported as a…
tchaymore
  • 3,508
  • 12
  • 44
  • 84
11
votes
2 answers

How to read quoted text containing escaped quotes

Consider the following comma separated file. For simplicity let it contain one line: 'I am quoted','so, can use comma inside - it is not separator here','but can\'t use escaped quote :=(' If you try to read it with the command table <-…
Max
  • 4,552
  • 4
  • 26
  • 32
11
votes
4 answers

ignore/remove NA values in read.csv

I have a csv file as shown below that I read into R using read.csv, where column C has 12/30 empty values. I want to work out the max of each column, but the R function "max" returns "NA" when used on column C. How do I get R to ignore the empty/NA…
moadeep
  • 3,522
  • 9
  • 41
  • 66
9
votes
2 answers

fread - read all columns as character

I'm trying to read a file into R using data.table / fread. Some of the fields have leading zeros and I just want to read the data in as characters and manually fix them. However I can't figure out how to convey this to fread. I'm trying this and…
screechOwl
  • 23,958
  • 54
  • 146
  • 246
8
votes
1 answer

length of 'dimnames' [2] not equal to array extent when using corrplot function from a matrix read from a csv file

I wanna read the data from a csv file, save it as a matrix and use it for visualization. data<-read.table("Desktop/Decision_Tree/cor_test_.csv",header = F,sep = ",") data V1 V2 V3 V4 V5 V6 1 1.00 0.00 0.00 0.00 0.00 0 2 0.11 …
Jeffrey Chen
  • 81
  • 1
  • 1
  • 2
8
votes
4 answers

Weird error in R when importing (64-bit) integer with many digits

I am importing a csv that has a single column which contains very long integers (for example: 2121020101132507598) a<-read.csv('temp.csv',as.is=T) When I import these integers as strings they come through correctly, but when imported as integers…
Zubin
  • 157
  • 2
  • 7
7
votes
2 answers

R: reading in .csv file removes leading zeros

I realize that reading a .csv file removes the leading zeros, but for some of my files, it maintains the leading zeros without my having to explicitly set colClasses in read.csv. On the other hand, what's confusing me is in other cases, it DOES…
user3755880
  • 335
  • 4
  • 13
7
votes
7 answers

Read.csv() throws error

I have been trying to read the excel file but seems like there is something wrong. The file is stored in Documents folder in excel format. These are the error messages that I get : table <- read.csv(file.choose(),header=T,sep='\t') Warning…
Minal Murkhande
  • 109
  • 1
  • 1
  • 3
7
votes
3 answers

Read.CSV not working as expected in R

I am stumped. Normally, read.csv works as expected, but I have come across an issue where the behavior is unexpected. It most likely is user error on my part, but any help will be appreciated. Here is the URL for the…
Btibert3
  • 34,187
  • 40
  • 119
  • 164
6
votes
1 answer

R 3.5 - read.csv not able to read UTF-16 csv file

My code is as follows: read.csv("http://asic.gov.au/Reports/YTD/2018/RR20180420-001-SSDailyYTD.csv", skip=1, fileEncoding = "UTF-16", sep = "\t", header = FALSE) R 3.4.3 - Code executes cleanly R 3.5.0 - gives the following error: Error in…
cephalopod
  • 1,574
  • 13
  • 23
6
votes
2 answers

R read.csv Importing Column Names Incorrectly

I have a csv that I would like to import into R as a data.frame. This csv has headers such as USD.ZeroCouponBondPrice(1m) and USD-EQ-SP500 that I can't change. When I try to import it into R, however, R's read.csv function overwrites the characters…
Theaetetos
  • 75
  • 1
  • 9
1
2
3
30 31