EVOLUTION-MANAGER
Edit File: chunkToLineReader.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Utility that collects data from the HTTP reply into lines and...</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for chunkToLineReader {RCurl}"><tr><td>chunkToLineReader {RCurl}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Utility that collects data from the HTTP reply into lines and calls user-provided function. </h2> <h3>Description</h3> <p>When one provides an R function to process the body of the R rep </p> <h3>Usage</h3> <pre> chunkToLineReader(f, verbose = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>f</code></td> <td> <p>a function that is to be called each time the <code>read</code> function is invoked and there are complete lines in that input.</p> </td></tr> <tr valign="top"><td><code>verbose</code></td> <td> <p>a logical value. If <code>TRUE</code>, information is displayed when there is any text that does not form a complete line and is held for processing in the next chunk. </p> </td></tr> </table> <h3>Details</h3> <p>This constructs a closure and then processes each chunk as they are passed to the read function. It strips away any text that does not form a complete line at the end of the chunk and holds this to be added to the next chunk being processed. </p> <h3>Value</h3> <p>A list with two components </p> <table summary="R valueblock"> <tr valign="top"><td><code>read</code></td> <td> <p>the function that will do the actual reading from the HTTP response stream and call the function <code>f</code> on each step (assuming the chunk has a line marker.</p> </td></tr> <tr valign="top"><td><code>comp2 </code></td> <td> <p>Description of 'comp2'</p> </td></tr> </table> <p>... </p> <h3>Author(s)</h3> <p>Duncan Temple Lang</p> <h3>References</h3> <p>Curl homepage <a href="http://curl.haxx.se">http://curl.haxx.se</a></p> <h3>See Also</h3> <p><code><a href="getURL.html">getURI</a></code> and the <code>write</code> argument. <code><a href="postForm.html">getForm</a></code>, <code><a href="postForm.html">postForm</a></code> <code><a href="curlPerform.html">curlPerform</a></code> </p> <h3>Examples</h3> <pre> # Read a rectangular table of data into R from the URL # and add up the values and the number of values read. summer = function() { total = 0.0 numValues = 0 list(read = function(txt) { con = textConnection(txt) on.exit(close(con)) els = scan(con) numValues <<- numValues + length(els) total <<- total + sum(els) "" }, result = function() c(total = total, numValues = numValues)) } s = summer() if(url.exists("http://www.omegahat.net/RCurl/matrix.data")) getURL("http://www.omegahat.net/RCurl/matrix.data", write = chunkToLineReader(s$read)$read) </pre> <hr /><div style="text-align: center;">[Package <em>RCurl</em> version 1.98-1.2 <a href="00Index.html">Index</a>]</div> </body></html>