At 10:08 20/12/2002 +1300, vous avez ?crit:
Hi, If I have a CSV file which has several comments at the top, and the data start immediately after the line: @DATA Is it possible to use the scan() command to get the CSV data into R, by only reading the lines after @DATA? If so, how can I do it? Cheers, Kevin
Here is a possible solution (if your data file is `yourfile.txt'):
tmp <- scan("yourfile.txt", what = "", sep = "\n")
skp <- grep("@DATA", tmp)
your.data <- scan("yourfile.txt", what = [...], skip = skp)
You may improve this by scanning line by line with:
scan("foo.txt", what = "", sep = "\n", n = 1, skip = s)
with s = 0, 1, 2, ... till you meet "@DATA".
Hope this helps.
EP
Emmanuel Paradis
Laboratoire de Pal?ontologie
Institut des Sciences de l'?volution
Universit? Montpellier II
F-34095 Montpellier c?dex 05
France
phone: +33 4 67 14 39 64
fax: +33 4 67 14 36 10
mailto:paradis at isem.univ-montp2.fr
http://www.isem.univ-montp2.fr/ISEMFre/Equipes/PPP/PPerso/ParadisE.php