s-news
[Top] [All Lists]

Re: function to download data from internet into Splus

To: nikolay <niskrev@umich.edu>
Subject: Re: function to download data from internet into Splus
From: Frank E Harrell Jr <fharrell@virginia.edu>
Date: Mon, 26 May 2003 21:42:01 -0400
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <001e01c323ee$11396ab0$690cd38d@Inspiration>
Organization: University of Virginia
References: <001e01c323ee$11396ab0$690cd38d@Inspiration>
On Mon, 26 May 2003 21:19:49 -0400
nikolay <niskrev@umich.edu> wrote:

> 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

Just install wget.exe where ftp.exe is stored in Windows.  Get wget.exe from 
http://ftp.sunsite.dk/projects/wget/windows/wget-1.8.1b.zip

> 
> "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 }
> 
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu.  To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message:  unsubscribe s-news


---
Frank E Harrell Jr              Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine  http://hesweb1.med.virginia.edu/biostat

<Prev in Thread] Current Thread [Next in Thread>