Message-ID: <OF7A5C2B46.CAFAAB4D-ON85256E2F.005B0393-85256E2F.005BA8AE@EU.novartis.net>
Date: 2004-02-03T16:39:44Z
From: ryszard.czerminski@pharma.novartis.com
Subject: problem with read.table
Any ideas why read.table complains about not correct number of elements in
line
while readLine/strsplit indicate that all lines have the same number of
elements ?
R
> tbl <- read.table('tmp', header = T, sep = '\t')
Error in scan(file = file, what = what, sep = sep, quote = quote, dec =
dec, :
line 32 did not have 27 elements
> lines <- readLines('tmp')
> v <- 1:length(lines)
> i <- 0; for (line in lines) { i <- i + 1; v[i] <- length(strsplit(line,
'\t')[[1]]) }
> v
[1] 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27
27 27
[26] 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27
27 27
[51] 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27
> sum((v - v[1])^2)
[1] 0
> length(strsplit(lines[32], '\t')[[1]])
[1] 27