Skip to content
Prev 82322 / 398513 Next

reading in data with variable length

On 12/6/05, John McHenry <john_d_mchenry at yahoo.com> wrote:
Building on Andy's variation:

n <- length(ta)
ta.sub <- sub("^[^,]*,[^.]*,", "", ta)
ta.con <- textConnection(ta.sub)
out <- replicate(n, scan(ta.con, nlines = 1, sep = ","))
close(ta.con)

Also consider writing ta.sub back out and defining ta.con as a
file connection to that file but testing both would be needed to
determine which is faster.