On Fri, 17 May 2002, juli g. pausas wrote:> Hi, > I have a data file with columns separated by ";" I read this file > without any problem using read.csv2( ) but I had problems trying to read > it with read.table( ... sep=";"). So it is not a problem for me, but I > wonder if there is a bug here.read.csv2 does just call read.table, so it can't be a bug in read.table. The issue is that line 16 has a single quote in, and read.csv2 sets the quote arg. So your call to read.table did exactly what you asked it too, the bug being in your understanding. Do look at the definition for read.csv2: it would have solved the problem for you.> > drt <- read.csv2("t.txt", header=TRUE) # ok > dcs <- read.table("t.txt", header=TRUE, sep=";") # wrong > > R.1.5.0. on Windows > > the file t.txt: > > codi;long;lat;alt;prov;nom > 8002;-0.65;38.72;816;A;BANYERES > 8003;-0.77;38.70;592;A;BENEIXAMA > 8003A;-0.78;38.70;580;A;BENEIXAMA, AGROMET > 8004;-0.77;38.63;754;A;BIAR, CASA PORSELL > 8005;-0.95;38.77;644;A;VILLENA, LA ENCINA > 8006;-0.98;38.70;557;AB;CAUDETE, DERRAMADOR > 8006I;-0.92;38.68;515;A;VILLENA, LA VEREDA > 8007;-0.87;38.63;505;A;VILLENA > 8009E;-0.87;38.47;560;A;MONOVER, EL ESVARADOR > 8010;-0.77;38.48;562;A;PETRER > 8011;-0.78;38.48;395;A;ELDA > 8013;-0.77;38.38;241;A;NOVELDA > 8014O;-0.97;38.42;555;A;XINORLET > 8015O;-0.88;38.37;500;A;LA ROMANA, AGROMET > 8018B;-0.70;38.27;86;A;ELX, CHS > 8019;-0.55;38.28;31;A;ALACANT, L'ALTET > 8024;-0.52;38.37;60;A;ALACANT, LA RABASA > > > Perphas the problem is that the last column have commas ... > So I'm not sure if this is a feature or a bug. > > juli > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"juli g. pausas" wrote:> > Hi, > I have a data file with columns separated by ";" I read this file > without any problem using read.csv2( ) but I had problems trying to read > it with read.table( ... sep=";"). So it is not a problem for me, but I > wonder if there is a bug here. > > drt <- read.csv2("t.txt", header=TRUE) # ok > dcs <- read.table("t.txt", header=TRUE, sep=";") # wrong > > R.1.5.0. on WindowsThat's not a bug! It's because of the different defaults of quote (there's a "'" in line 17). You can use e.g. read.table("t.txt", header=TRUE, sep=";", quote="\"") Uwe Ligges> the file t.txt: > > codi;long;lat;alt;prov;nom > 8002;-0.65;38.72;816;A;BANYERES > 8003;-0.77;38.70;592;A;BENEIXAMA > 8003A;-0.78;38.70;580;A;BENEIXAMA, AGROMET > 8004;-0.77;38.63;754;A;BIAR, CASA PORSELL > 8005;-0.95;38.77;644;A;VILLENA, LA ENCINA > 8006;-0.98;38.70;557;AB;CAUDETE, DERRAMADOR > 8006I;-0.92;38.68;515;A;VILLENA, LA VEREDA > 8007;-0.87;38.63;505;A;VILLENA > 8009E;-0.87;38.47;560;A;MONOVER, EL ESVARADOR > 8010;-0.77;38.48;562;A;PETRER > 8011;-0.78;38.48;395;A;ELDA > 8013;-0.77;38.38;241;A;NOVELDA > 8014O;-0.97;38.42;555;A;XINORLET > 8015O;-0.88;38.37;500;A;LA ROMANA, AGROMET > 8018B;-0.70;38.27;86;A;ELX, CHS > 8019;-0.55;38.28;31;A;ALACANT, L'ALTET > 8024;-0.52;38.37;60;A;ALACANT, LA RABASA > > Perphas the problem is that the last column have commas ... > So I'm not sure if this is a feature or a bug. > > juli > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi, I have a data file with columns separated by ";" I read this file without any problem using read.csv2( ) but I had problems trying to read it with read.table( ... sep=";"). So it is not a problem for me, but I wonder if there is a bug here. drt <- read.csv2("t.txt", header=TRUE) # ok dcs <- read.table("t.txt", header=TRUE, sep=";") # wrong R.1.5.0. on Windows the file t.txt: codi;long;lat;alt;prov;nom 8002;-0.65;38.72;816;A;BANYERES 8003;-0.77;38.70;592;A;BENEIXAMA 8003A;-0.78;38.70;580;A;BENEIXAMA, AGROMET 8004;-0.77;38.63;754;A;BIAR, CASA PORSELL 8005;-0.95;38.77;644;A;VILLENA, LA ENCINA 8006;-0.98;38.70;557;AB;CAUDETE, DERRAMADOR 8006I;-0.92;38.68;515;A;VILLENA, LA VEREDA 8007;-0.87;38.63;505;A;VILLENA 8009E;-0.87;38.47;560;A;MONOVER, EL ESVARADOR 8010;-0.77;38.48;562;A;PETRER 8011;-0.78;38.48;395;A;ELDA 8013;-0.77;38.38;241;A;NOVELDA 8014O;-0.97;38.42;555;A;XINORLET 8015O;-0.88;38.37;500;A;LA ROMANA, AGROMET 8018B;-0.70;38.27;86;A;ELX, CHS 8019;-0.55;38.28;31;A;ALACANT, L'ALTET 8024;-0.52;38.37;60;A;ALACANT, LA RABASA Perphas the problem is that the last column have commas ... So I'm not sure if this is a feature or a bug. juli -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._