R

Install

sudo apt-get build-dep r-base

sudo apt-get install r-base-core

install.packages('forecast',dep=TRUE,clean=TRUE)

update.packages()

R CMD INSTALL packages.tar.gz

library(forecast)

library(gsarima)

summary(x)

attributes(x)

require("forecast")

require("expsmooth")

library(forecast)

library(gsarima)

require(stats)

require(tikzDevice)

require(Rwave)

require("fUnitRoots")

sudo apt-get build-dep r-base

sudo apt-get install r-base-core

install.packages('forecast',dep=TRUE,clean=TRUE)

install.packages(c("pkg1", "pkg2"),dep=TRUE,clean=TRUE)

install.packages(c("alabama", "BB", "boot", "clue", "cmaes", "dclone", "DEoptim", "desirability", "gafit", "genalg", "glpk", "goalprog", "gsl", "igraph", "kernlab", "limSolve", "linprog", "LowRankQP", "lpSolve", "lpSolveAPI", "maxLik", "mco", "minpack.lm", "minqa", "neldermead", "nleqslv", "optimx", "optmatch", "pso", "quadprog", "quantreg", "rcdd", "Rcgmin", "Rcplex", "RcppDE", "Rcsdp", "rgenoud", "Rglpk", "Rmosek", "rneos", "ROI", "Rsolnp", "Rsymphony", "Rvmmin", "sna", "soma", "subplex", "trust", "TSP", "ucminf"),dep=TRUE,clean=TRUE)

update.packages()

R CMD INSTALL packages.tar.gz

library(forecast)

library(gsarima)

summary(x)

attributes(x)

RSiteSearch('topic')

sessionInfo()

apropos(table) #Find Objects by (Partial) Name

ls() #shows the variables in the workspace

help (name) #provides help about "name"

? name #does the same

rm(variable) #removes that variable

rm(list = ls()) #removes all variables from the work space

names(table) #what are the variables inside the table

variable <-c(value1,value2,value3 ...) #assigns values to a variable.

newvariable <- cbind (variable1, variable2, variable3 ... variable n)# make up a new array with these variables

library(gregmisc)

permutations(3, 3, letters[1:3])

library(sciplot)

lineplot.CI

lm : used to fit linear models

x1 <- runif(100)

x2 <- rexp(100)

y <- 3 + 4*x1 + 5*x2 + rnorm(100)

mod <- lm(y~x1+x2)

plot(mod)

set.seed(12345)

res1<-rbinom(10000,1,.1)

rdata3<-transform(data.frame(res1),

mdat <- matrix(c(1,2,3,11,12,13,21,22,23), nrow = 3, ncol=3, byrow=TRUE,)

mdat

matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE,dimnames = NULL)

c(list(A=c(1,2), B=c(E=7)), recursive=TRUE)

c(list(A=c(1,2), B=c(E=7,2,3,4,5)), recursive=TRUE)

c(list(A=c(1,2,A=10), B=c(E=7,2,3,4,5)), recursive=TRUE)

x<-read.table(trc)

x<-scan("trace")

write.table(b[], file = "aa.txt")

#write(wframe[i], file = "ufhfui",append = TRUE, sep = "\n")

unlink("output_file")

>sprintf( "%05f", x )

> formatC(c(1, 19), flag=0, width=3)

edit pdf

options(useFancyQuotes=FALSE)

system(noquote(paste

("pdftools -S",dQuote(paste("attachfiles=C:\\test1.pdf|C:\\Document-1.pdf")),paste("-i C:\\test2.pdf -o C:\\test3.pdf"))

))

# create a 2 by 5 matrix

x <- 1:10

attr(x,"dim") <- c(2, 5)

x<-read.table("trc")

write.table

mean(x)

> a<- matrix(c(1,3,2,4),nrow=2,ncol=2,)

> a

[,1] [,2]

[1,] 1 2

[2,] 3 4

> b<-matrix(c(0,6,5,7),nrow=2,ncol=2,)

> b

[,1] [,2]

[1,] 0 5

[2,] 6 7

> a%x%b #Kronecker product

[,1] [,2] [,3] [,4]

[1,] 0 5 0 10

[2,] 6 7 12 14

[3,] 0 15 0 20

[4,] 18 21 24 28

if( any(x <= 0) )

y <- log(1+x)

else

y <- log(x)

y <- if( any(x <= 0) ) log(1+x) else log(x)

require(stats)

centre <- function(x, type) {

switch(type,

mean = mean(x),

median = median(x),

trimmed = mean(x, trim = .1))

}

x <- rcauchy(10)

centre(x, "mean")

centre(x, "median")

centre(x, "trimmed")

ccc <- c("b","QQ","a","A","bb")

for(ch in ccc)

cat(ch,":", switch(EXPR = ch, a=1,b=2:3), "\n")

for(ch in ccc)

cat(ch,":", switch(EXPR = ch, a=, A=1, b=2:3, "Otherwise: last"),"\n")

for(i in c(-1:3,9)) print(switch(i, 1,2,3,4))

test1 <- function(x = pi, dig = 3)

{

oo <- options(digits = dig); on.exit(options(oo));

cat(.Options$digits, x, "\n")

}

test2 <- function(x = pi, dig = 3)

{

.Options$digits <- dig

cat(.Options$digits, x, "\n")

}

switch(1, invisible(pi), pi)

switch(2, invisible(pi), pi)

dump("x", file=stdout())