# Reading files
# We need a special function because, although simple http:// URLs
# can be handled just like local file paths, https:// cannot,
# so we need at least one special case
# NOTE that although we claim to handle URLs as well as local files,
# we can only handle URLs to STATIC resources; this is not an
# interface to resources that are dynamically generated by a server
fileType <- function(x) {
if (grepl("^ *https://", x))
"https"
else if (grepl("^ *http://", x))
"http"
else
"plain"
}
readFile <- function(x) {
UseMethod("readFile")
}
readFile.default <- function(x) {
readLines(x)
}
readFile.https <- function(x) {
require(RCurl)
getURL(x)
}
# This function should only ever be given an absolute path
# This function is only designed for reading text files
readRef <- function(x) {
ft <- fileType(x)
class(x) <- c(ft, class(x))
readFile(x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.