err <- F err <- tryCatch({cal <- replace("aaa", "aaa") }, #replace 覈視. error = function(e){return(T)}, warning = function(e){return(T)}) err #err 螳 T襦 覦
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
R CMD BATCH --no-save --no-restore '--args a=1 b=c(2,5,6)' test.R test.out
##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)
fit1 <-lm(Volume~., data=trees) saveRDS(fit1, "d:\\fit1.rds") fit1 <- readRDS("d:\\fit1.rds") summary(fit1)