Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 13:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
path <- "state07_DE.txt"
col.widths <- c(6, 4, 2, 4)
table.header <- c("COOP.ID", "YEAR", "MONTH", "ELEMENT")
for(i in 1:31) {
new.widths <- c(5, 1, 1, 1)
new.header <- c(paste("VALUE",i, sep=""),
paste("MFLAG",i, sep=""),
paste("QFLAG",i, sep=""),
paste("SFLAG",i, sep=""))
col.widths <- append(col.widths, new.widths)
table.header <- append(table.header, new.header)
print("Time for regular read:")
system.time(data1 <- read.fwf(file=path, widths=col.widths, header=FALSE, col.names=table.header))
print("Time for")
system.time(data2 <-, width=col.widths, col.names=table.header))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment