000.readText: Reads the content of a local or an online text file

Description Usage Arguments Value Caching URL Newline substitution Author(s)


Reads the content of a local or an online text file.


.readText(con, ..., maxAge=getOption("R.rsp::downloadIfOlderThan", -Inf))



A character string specifying a local file or a URL, or a connection.


Not used.


A numeric scalar specifying the maximum age (in seconds) of cached URL contents before downloading and recaching. If zero or less, the URL will always be downloaded.


Returns a character string.

Caching URL

When reading online URLs, it may take time a significant time to read its content. If the content is changing rarely, it is possible to cache the content locally. If a cached version is found, then it is read instead. It is possible to control how often a file should be recached. If the cache is older than argument maxAge (in seconds), then the file is redownloaded and recached.

Newline substitution

All occurrences of \r\n and \r are replaced with \n such that all lines are ending in \n regardless of encoding.


Henrik Bengtsson

R.rsp documentation built on July 9, 2020, 5:09 p.m.