_覓 | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁 |
FrontPage › R蠍磯ル
|
|
[edit]
1 語襴(tryCatch) #err <- F err <- tryCatch({cal <- replace("aaa", "aaa") }, #replace 覈視. error = function(e){return(T)}, warning = function(e){return(T)}) err #err 螳 T襦 覦 [edit]
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 [edit]
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) [edit]
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)
鏤
|
る 伎 覈詩 蟆企朱 襦 蠍 伎 願 螻 襷 殊 襦 . (ろ磯 誤) |