Hi All,
given below is an example of a function written by Diethelm Wurtz with which
one can download data from a web site (econmagic.com) into Splus. The
function works under Unix. Does anyone know an easy way to make it work with
Splus 6.0 under Windows
Thanks
"import.data.economagic" <- function(file, source, query) {
# Download Data:
tmpfile <- tempfile(file); on.exit(unlink(tmpfile))
print("Starting Internet Download ...")
system(paste("bin\\wget -O ", file, " ", source, query, sep=""),
on.exit.status="stop", minimized=T)
print("Data successfully downloaded ...")
system(paste("bin\\cat ", file, " | bin\\grep '^ [12][90].. [01].' > ",
tmpfile, sep=""), on.exit.status="stop", minimized=T)
# Transform Data:
z <- read.table(tmpfile)
z <- data.frame(cbind(z[,1]*100+z[,2], z[,3:(length(names(z)))]))
# Save as Data Frame:
znames <- as.character(1:(length(names(z))-1))
names(z) <- c("DATE", znames)
write.table(z, file=file, dimnames.write="colnames")
# Return Result:
z }
|