Error R csv: Error in read.table(file = file, header = header, sep = sep, quote = quote, : file must be a character string or connection

Error R csv: Error in read.table(file = file, header = header, sep = sep, quote = quote, : file must be a character string or connection

Ive finally solved the problem, even if it doesnt seem a clean solution, it works. I guess the problem was that some extra were added to the original files when I took them to the console so I rewrite the files and re-added the recently created files to the console.

r – read.csv warning EOF within quoted string prevents complete reading of file

RNA <- read.table(RNA.csv, dec = ,, sep = ;, stringsAsFactors = FALSE, header = TRUE, blank.lines.skip = TRUE)
tRNA <- t(RNA)
write.table(tRNA, file = tRNA_2.csv, quote = FALSE, dec = ., sep = ,, qmethod = escape)
tRNAt <- read.csv(tRNA_2.csv)

miRNA <- read.table(miRNA.csv, dec = ,, sep = ;, stringsAsFactors = FALSE, header = TRUE, blank.lines.skip = TRUE)
tmiRNA <- t(miRNA)
write.table(tmiRNA, file = tmiRNAt.csv, quote = FALSE, dec = ., sep = ,, qmethod = escape)
tmiRNAt <- read.csv(tmiRNAt.csv)

dataset <- cbind2(x=tmiRNAt, y = tRNAt)
write.table(dataset, file = dataset_2.csv, quote = FALSE, dec = ., sep = ,, qmethod = escape)

# MiRLAB:
library(miRLAB)
cause = 1:278
effect = 279:length(dataset)
ps = Pearson(dataset_2.csv, cause = cause, effect = effect)

I know its not a good idea to write and read so many times but its actually the way that it have worked better (worked at all).

Thank you for your help!

here is an example:

# working:
# create csv file with , seprator
write.table(x = mtcars, file = data.csv, sep = ,, row.names = F)
Pearson(datacsv = data.csv, cause = 2:3, effect = 3:4)

#           cyl      disp
#disp 0.9020329 1.0000000
#hp   0.8324475 0.7909486


# not work:
# create csv file with ; seprator
write.table(x = mtcars, file = data1.csv, sep =  ; , row.names = F, col.names = F)
Pearson(datacsv = data1.csv, cause = 2:3, effect = 3:4)

the inner read.csv uses default seprator ,
just change your file and replace all semicolon with comma

Error R csv: Error in read.table(file = file, header = header, sep = sep, quote = quote, : file must be a character string or connection

Leave a Reply

Your email address will not be published. Required fields are marked *