Skip to content
Prev 299629 / 398503 Next

Skipping lines and incomplete rows

Hello,

My approach was slightly different, to use readLines to take care of the 
header and read.table for the data. This works with the new dataset 
you've posted, but we must use the option comment.char = "".

Try the following.


head <- readLines("test.txt", n=4)[4]
dat <- read.table("test.txt", skip=5, sep=";", stringsAsFactors=FALSE, 
comment.char="c")
names(dat) <- unlist(strsplit(head, ";"))

dat$Time <- as.Date(dat$Time, format="%m/%d/%Y")
dat$Temp[dat$Temp == '#N/A'] <- NA
dat$Press[dat$Press == '#N/A'] <- NA
dat


It works with me, good luck.

Rui Barradas

Em 10-07-2012 06:41, vioravis escreveu: