[R] parsing a data file

Eric Lecoutre lecoutre at stat.ucl.ac.be
Tue Apr 27 12:15:10 CEST 2004


Oups,

I realize i do remove the last value with my code...
Better remove then from text directly:


readRecords = function(file){

	tmptxt = readLines(file)
	tmptxt = paste(tmptxt,collapse=" ") # All as a single string
	tmptxt=substr(tmptxt, 6,nchar(tmptxt)-3)# remove BEGIN and END
	tmptxt = strsplit(tmptxt,"RECORD")[[1]]
	
	num = as.numeric(tmptxt)
	return(num)
}

Eric
---
Eric Lecoutre
UCL /  Institut de Statistique
Voie du Roman Pays, 20
1348 Louvain-la-Neuve
Belgium

tel: (+32)(0)10473050
lecoutre at stat.ucl.ac.be
http://www.stat.ucl.ac.be/ISpersonnel/lecoutre

If the statistics are boring, then you've got the wrong numbers. -Edward 
Tufte




More information about the R-help mailing list