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
6
votes
3 answers

read.csv replaces column-name characters like `?` with `.`, `-` with `...`

I'm using RStudio and my output on the Console gets truncated. I can't find how to stop the truncation (I tried searching ?options as well as googling around for longer than I'd like to admit). EDIT: My apologies everyone! I originally had the…
Will
  • 10,218
  • 8
  • 62
  • 72
6
votes
3 answers

Skip all leading empty lines in read.csv

I am wishing to import csv files into R, with the first non empty line supplying the name of data frame columns. I know that you can supply the skip = 0 argument to specify which line to read first. However, the row number of the first non empty…
Alex
  • 13,293
  • 9
  • 60
  • 113
6
votes
2 answers

read.csv Read Specific Row

How can we read specific rows into R using the read.csv command? Say if I have a CSV file which has 10 rows of data, and I just want to only read the 5th row of data, I tried doing the following but it doesn't seem to be working: myFile <-…
Outrigger
  • 139
  • 1
  • 3
  • 10
5
votes
1 answer

Skipping specific rows and columns in R

I skipped second row of the data using this command: Df=(read.csv(“IMDB_data.csv”, header=T, sep=",")[-2,]) What is the explanation behind this? Can it be used for skipping more than 1 specific row? Can it used for skipping columns? Please help.
user9716225
  • 53
  • 1
  • 4
5
votes
4 answers

Skipping last column in r with read.csv

I was on that post read.csv and skip last column in R but did not find my answer, and try to check directly in Answer ... but that's not the right way (thanks mjuarez for taking the time to get me back on track. The original question was: I have…
5
votes
2 answers

Merge multiple .csv files into one

I am aware this question has been asked multiple times, but despite of trying to apply the aforementioned solutions i was not able to solve my little problem: I have saved all my .csv that i am aiming to merge into one folder: > file_list <-…
Nneka
  • 1,268
  • 2
  • 10
  • 26
5
votes
0 answers

R dates automatically detected when reading in .csv files?

I have a chunk of code that I regularly run to read in and clean up a.csv file. Part of the clean up process is to identify date columns and convert them to the correct format, which I do with a function (see below). I set the date format to…
Amy M
  • 647
  • 6
  • 17
5
votes
3 answers

Error in file(file, "rt") : cannot open the connection - cannot open file 'specdata' access denied

I'm running rStudio v3.1.2 on Windows 7. This laptop is a 64-bit machine. I'm taking the JHU R Programming course offered by Coursera and am stuck on an error I'm receiving in part 1 of the problem. I have some error handling functions I'm keeping…
ASwiftPeregrine
  • 131
  • 1
  • 1
  • 10
5
votes
1 answer

Insert NA values into dataframe blank cells when importing read.csv/read.xlsx

The attached screenshot shows part of a dataframe which I have just imported into R from an excel file. In the cells which are blank, I need to insert 'NA'. How can I insert NA into any cell which is blank (whilst leaving the already populated cells…
luciano
  • 11,848
  • 27
  • 77
  • 118
4
votes
1 answer

read.csv() - two out of three columns

Possible Duplicate: Only read limited number of columns in R I have a ascii-dataset which consists of three columns, but only the last two are actual data. Now I want to dotchart the data by using read.csv(file = "result1", sep= " "). R reads all…
user2442121
4
votes
1 answer

Extra commas at end of lines causing error with read.csv and read.table

I am trying to read this .csv file into R. When I use read.csv, I either get errors related to row.names, or the column names are offset from their original columns. Based on this post I believe the problem is related to having an extra comma at the…
Josh
  • 998
  • 7
  • 22
4
votes
2 answers

How to read csv with values containing commas in R?

I have a tool (exe provided to me), which outputs poorly formatted csv's. They are bad in that the last value can have commas, with no quotes, e.g.: 184500,OBJECT_CALENDAR,,,UNITS_NO_UNITS,NULL,,,,Sched N&S B1,1st,3rd,4S,5th&6th Where the last…
lukehawk
  • 1,183
  • 3
  • 17
  • 43
4
votes
1 answer

reading comma-separated strings with read.csv()

I am trying to load a comma-delimited data file that also has commas in one of its text columns. The following sample code generates such a file'test.csv',which I'll load usingread.csv()to illustrate my problem. > d <- data.frame(name = c("John…
Manojit
  • 375
  • 2
  • 12
4
votes
1 answer

Constantly scanning for new files in R working directory

Is there a way to make R continuously scan the working directory for new files (in this case, CSVs), and whenever it finds a new file has been added to the working directory, to read it and perform some (always the same) task on it, and then go back…
4
votes
1 answer

Dealing with Byte Order Mark (BOM) in R

Sometimes a Byte Order Mark (BOM) is present at the beginning of a .CSV file. The symbol is not visible when you open the file using Notepad or Excel, however, When you read the file in R using various methods, you will different symbols in the name…
Gaurav Singhal
  • 850
  • 2
  • 7
  • 22
1 2
3
30 31