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.

737 questions
0
votes
0 answers

How to read a csv table where some rows contain "\n" in R

I am trying to read a csv file that I created in R. Some rows contain the following character name: "Drug a + Drug B \n Drug C + Drug D" When I want to read it, I do not have the part after the \n and additionnal rows with NA are added. So my…
Aziz
  • 9
  • 1
0
votes
1 answer

Change the coltypes based on a substring in colnames

I have a very large data frame of sales data (df8). When loading in, some of the variables that I want to be numeric loaded as chr. I want to change every column where the colname contains the word "Order" from chr to numeric. How can I do this?
s.poo57
  • 39
  • 1
  • 6
0
votes
1 answer

Importing unfriedly formatted data in Excel and forcing messy values as column names

I'm trying to import some publicly available life outcomes data using the code below: require(gdata) # Source SIMD12 data zone level data simd.sg.xls <- read.xls(xls = "http://www.gov.scot/Resource/0044/00447385.xls", sheet…
Konrad
  • 17,740
  • 16
  • 106
  • 167
0
votes
1 answer

Reading and concatenating CSV files with varying (nrow, ncol) dimensions

I have a directory of tab separated log files with varying dimensions and I am trying to load them into R. Dir: File1 (col1,col2,col3) File2 (col3,col4,col5,col6,col7) File3 (col1,col8,col9,col10) To do this: I concatenated all the files in the…
BRZ
  • 695
  • 4
  • 13
  • 25
0
votes
0 answers

load data infile format general col type to numeric

I am importing a .csv into a MySql table using LOAD DATA INFILE and would like to find a way around columns containing formatting like "6.10111E+11" -- this should import as "610111447853" but is instead 610111000000. The table col is VARCHAR as…
caro
  • 863
  • 3
  • 15
  • 36
0
votes
1 answer

lappy to call read.csv over a list

I am creating a list of filenames new <- as.list(filename1) which looks like below: [[9]] [1] "test/a.csv" [[10]] [1] "test/b.csv" and then I am writing the below lapply to load each file to a data.frame(df) assuming that lapply will go over…
Suren Baskaran
  • 1,228
  • 1
  • 10
  • 17
0
votes
0 answers

Random X variable data table R

When I read in a .csv I previously wrote out, there are random and undesired "X" and "X.1" variables. How do I avoid this? I am writing the csv as such write.csv(bind.data,paste("bind.data.same.rm",Sys.Date(),".csv",sep="")) And reading it…
Pablo Boswell
  • 805
  • 3
  • 13
  • 30
0
votes
3 answers

R read.csv didn't load all rows of .tsv file

A little mystery. I have a .tsv file that contains 58936 rows. I loaded the file into R using this command: dat <- read.csv("weekly_devdata.tsv", header=FALSE, stringsAsFactors=TRUE, sep="\t") but nrow(dat) only shows this: > nrow(dat) [1]…
Jazzmine
  • 1,837
  • 8
  • 36
  • 54
0
votes
1 answer

R read.dta and unz not working

I read a lot of files into R from zipped sources. I try to use the R function unz to read from zipped files because unlike unzip it does not leave any unzipped files on my harddisk. However, this does not seem to work for zipped *.dta (Stata)…
roming
  • 1,165
  • 1
  • 9
  • 22
0
votes
1 answer

Current status of colClasses argument in function ff:read.csv.ffdf (ff - R package)

Error vmode 'character' not implemented occours due to argument colClasses=c("id"="character") in below code : df <- read.csv.ffdf('TenGBsample.csv', colClasses=c("id"="character"), VERBOSE=TRUE) read.table.ffdf 1..1000 (1000) …
Qbik
  • 5,885
  • 14
  • 62
  • 93
0
votes
2 answers

separating into columns in r - delimiter changes

I want to split values contained in a single column into new columns. I have some data that looks like this in a file: > df V1 1 00006303657102064942660780914135165036 12867 15476 15473 15474 15397 14050 2 00006319625527159782351492300309533775…
vagabond
  • 3,526
  • 5
  • 43
  • 76
0
votes
2 answers

fread: read certain row as implicitly ordered factor

I am fairly new to R, and have been using data.table a lot recently for a project involving manipulation of large data sets, specifically genome data. One of the columns is the chromosome number/name, which is formatted as "chr_", where the _ is…
archaephyrryx
  • 415
  • 2
  • 10
0
votes
2 answers

How do I loop over the rows of a data frame without relying on locational references to Column in R

I have figured out how to create a new column on my data frame that = TRUE if the character string in "Column 5" is contained within the longer string in "Column 6" - can I do this by referring to the names of my columns rather than using [r,c]…
user3381203
  • 21
  • 1
  • 3
0
votes
0 answers

How to optimize read.csv

I have several large (600000+ rows, ~50 columns) CSV file I import in R through read.csv(). Each reading takes precious minutes of my time, so I would like to speed up this step as much as possible. One thing I've done is previously identify the…
Waldir Leoncio
  • 10,853
  • 19
  • 77
  • 107
0
votes
0 answers

read.csv in R returns nothing

I'm brand new to R and having a basic issue. I need to import a file "testfile.csv" and store it in a variable called "data". I have my working directory set correctly (I think), but my file only contains a single column of values. When I run the…
marc
  • 2,037
  • 9
  • 24
  • 32