library(miniCRAN)
if(!"repos"%in%names(formals(utils::available.packages))) assignInNamespace("pkgAvail",
function (repos = getOption("repos"), type = "source", Rversion = R.version,
quiet = FALSE)
{
if (!grepl("^http://|file:///", repos[1]) && file.exists(repos[1])) {
repos <- paste0("file:///", normalizePath(repos[1], mustWork = FALSE,
winslash = "/"))
}
else {
if (!is.null(names(repos)) && isTRUE(unname(repos["CRAN"]) ==
"@CRAN@")) {
repos <- MRAN()
}
}
ap <- function() {
utils::available.packages(miniCRAN:::contribUrl(repos, type = type,
Rversion = Rversion), type = type, filters = list())
}
if (quiet)
suppressWarnings(ap())
else ap()
}, pos="package:miniCRAN")
repo <- "https://cran.rstudio.com"
pkgs <- c("rvest", 'httr', 'jiebaR')
pkgList <- pkgDep(pkgs ,repos=repo, type="source",
suggests=FALSE)
makeRepo(pkgList, path="~/crantest2", repos=repo,
type=c("source"))
library(tools)
write_PACKAGES("~/crantest2/src/contrib", type="source")
uri <- paste0("file:///"
, normalizePath("~/crantest2"))
uri
options(repos = c(CRAN=uri))
getOption("repos")
available.packages(type="source")
install.packages('rvest',repos=c(CRAN=uri))
library(httr)
res <- GET('http://0.0.0.0:8000/echo?name=David')
content(res)
data(iris)
library(rpart)
fit <- rpart(Species ~., data = iris)
save(x = fit, file='model.RData')
load('model.RData')
plot(fit)
#predict(fit, data = iris, type= 'class')
a <- data.frame(
Sepal.Length = 3,
Petal.Length = 5,
Sepal.Width = 3,
Petal.Width = 7)
predict(fit, a, type= 'class')
library(httr)
res2 <- POST('http://0.0.0.0:8000/predict', body = list(sl = 3, sw = 3, pl = 5, pw = 5), encode = 'form')
content(res2)
library(plumber)
r <- plumb("demo.R")
r$run(host = '0.0.0.0',port=8000)
library(pmml)
saveXML(pmml(fit), "iris.pmml")
Sys.setenv(HADOOP_CMD="/usr/local/hadoop/bin/hadoop")
library(rhdfs)
hdfs.init()
f = hdfs.file("a.RData","w")
data(iris)
hdfs.write(list(a=1, b=2),f)
hdfs.close(f)
f = hdfs.file("a.RData", "r")
dfserialized <- hdfs.read(f)
df <- unserialize(dfserialized)
df
hdfs.close(f)