inst/doc/practical2.R

## ----echo=FALSE----------------------------------------------------------
results = "hide"; echo = FALSE


## ----setup, include=FALSE, cache=FALSE-----------------------------------
library(knitr)
options(replace.assign=FALSE,width=50)


## ------------------------------------------------------------------------
library("nclRcourses")


## ------------------------------------------------------------------------
x1 = GetNumericVector()


## ----echo=echo, results=results------------------------------------------
length(x1)


## ----echo=echo, results=results------------------------------------------
x1[55]


## ----echo=echo, results=results------------------------------------------
x1[length(x1)]
tail(x1, 1)


## ----echo=echo, results=results------------------------------------------
mean(x1)


## ----echo=echo, results=results------------------------------------------
min(x1)


## ----echo=echo, results=results------------------------------------------
q1 = quantile(x1)[2]
med = median(x1)
length(x1[x1 > q1 & x1 < med])

##Or
sum(x1 > q1 & x1 < med)


## ----echo=echo, results=results------------------------------------------
m = mean(x1)
s = sd(x1)
sum(x1 > (m + 2*s))


## ----echo=echo, results=results------------------------------------------
sort(x1)[50]


## ------------------------------------------------------------------------
y = GetDataFrame()


## ----echo=echo, results=results------------------------------------------
dim(y)[1]


## ----echo=echo, results=results------------------------------------------
dim(y)[2]


## ----echo=echo, results=results------------------------------------------
unique(y$type)


## ----echo=echo, results=results------------------------------------------
sum(y$type == "mutant")


## ----echo=echo, results=results------------------------------------------
sum(y$value < 5)


## ----echo=echo, results=results------------------------------------------
sum(y$tps == 0)


## ----echo=echo, results=results------------------------------------------
sum(y$tps == 0 & y$type == "mutant")


## ------------------------------------------------------------------------
x2 = GetCharacterVector()


## ----echo=echo, results=results------------------------------------------
length(x2[x2=="A"])
##Or
sum(x2=="A")


## ----echo=echo, results=results------------------------------------------
sort(table(x2), decreasing=TRUE)[1]


## ----echo=echo, results=results------------------------------------------
l = length(x2)
x2_a = x2[1:(l-1)]; x2_b = x2[2:l];
sum(x2_a == x2_b)  

Try the nclRcourses package in your browser

Any scripts or data that you put into this service are public.

nclRcourses documentation built on May 2, 2019, 5:55 p.m.