chunkToLineReader | R Documentation |
When one provides an R function to process the body of the R rep
chunkToLineReader(f, verbose = FALSE)
f |
a function that is to be called each time
the |
verbose |
a logical value. If |
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.
A list with two components
read |
the function that will do the actual reading from the
HTTP response stream and call the function |
comp2 |
Description of 'comp2' |
...
Duncan Temple Lang
Curl homepage https://curl.se/
getURI
and the write
argument.
getForm
, postForm
curlPerform
# 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()
## Not run:
## broken, 2022-07-29
if(url.exists("https://www.omegahat.net/RCurl/matrix.data"))
getURL("https://www.omegahat.net/RCurl/matrix.data", write = chunkToLineReader(s$read)$read)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.