_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › R蠍磯ル

Contents

1 語襴(tryCatch)
2 Pipe 蠍
3 覦危 貊襦 貉危狩蠍(焔ロレ)
4 Including arguments in R CMD BATCH mode
5 r object /覿り鍵
6 install.packages
7 PMML
8 R-Stuido Server れ蠍


1 語襴(tryCatch) #

err <- F
err <- tryCatch({cal <- replace("aaa", "aaa") }, #replace   覈視.
     error = function(e){return(T)}, warning = function(e){return(T)})
err #err 螳 T襦 覦

3 覦危 貊襦 貉危狩蠍(焔ロレ) #

x <- 1:10000000
y <- 1:10000000

#
f <- function(){
  for(i in 1:length(x)){
    z[i] <<- i[i] + y[i]
  }
}

#覦危語 貉危
library(compiler)
cf <- cmpfun(f)

蟆郁骸
> start.time <- Sys.time()
> z <- x + y #覯″ 一
> Sys.time() - start.time
Time difference of 0.03900194 secs
> start.time <- Sys.time()
> f() #R 
> Sys.time() - start.time
Time difference of 24.81421 secs
> start.time <- Sys.time()
> cf() #覦危語襦 貉危朱 R 
> Sys.time() - start.time
Time difference of 5.823333 secs

4 Including arguments in R CMD BATCH mode #

豢豌: http://www.r-bloggers.com/including-arguments-in-r-cmd-batch-mode/
R CMD BATCH --no-save --no-restore '--args a=1 b=c(2,5,6)' test.R test.out 

test.R
##First read in the arguments listed at the command line
args=(commandArgs(TRUE))

##args is now a list of character vectors
## First check to see if arguments are passed.
## Then cycle through each element of the list and evaluate the expressions.
if(length(args)==0){
    print("No arguments supplied.")
    ##supply default values
    a = 1
    b = c(1,1,1)
}else{
    for(i in 1:length(args)){
         eval(parse(text=args[[i]]))
    }
}
print(a*2)
print(b*3)

5 r object /覿り鍵 #

http://www.fromthebottomoftheheap.net/2012/04/01/saving-and-loading-r-objects/
fit1 <-lm(Volume~., data=trees)
saveRDS(fit1, "d:\\fit1.rds")

fit1 <- readRDS("d:\\fit1.rds")
summary(fit1)

6 install.packages #

install.packages("RMySQL", repos='http://cran.r-project.org', dependencies = TRUE)

install.packages("foo.zip", repos = NULL)

7 PMML #

library(nnet)
model <- nnet(Species~., data=iris, size=4)

library(pmml)
pmml(model)

8 R-Stuido Server れ蠍 #

蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

碁レ 螻朱覿 煙隈螻 る朱覿 覓企讌. (蟯)