Basics in R - First class
~~~{
r
}
x=c(2,5,7,1,3,4,5)
# Mean, Median & Mode
mean(x)
[1] 3.857143
median(x)
[1] 4
library(LaplacesDemon)
Mode(x)
[1] 5
Calculate Variance, SD and Range
~~~~~~{
r
}
var(x)
[1] 4.142857
sd(x)
[1] 2.035401
range(x)
[1] 1 7
min(x)
[1] 1
max(x)
[1] 7
range=(max-min)
Error in max - min : non-numeric argument to binary operator
range
function (..., na.rm = FALSE) .Primitive("range")
range(x)
[1] 1 7
Simple BODMAS function
~~~~~~{
r
}
x=5
y=3
z=x+y*x/y
z
[1] 10
Probability and checking if data is following the Normal Distribution
~~~~~~{
r
}
x=c(6,5,3,8,9,2,1,3,5,8,5)
pnorm(x)
[1] 1.0000000 0.9999997 0.9986501 1.0000000 1.0000000 0.9772499 0.8413447 0.9986501
[9] 0.9999997 1.0000000 0.9999997
qqnorm(x)
qnorm(0.977)
[1] 1.995393
qnorm(0.995)
[1] 2.575829
view(x)
Error in view(x) : could not find function "view"
View(x)
tail(x)
[1] 2 1 3 5 8 5
tail(x,3)
[1] 5 8 5
dim(x)
NULL
head(x)
[1] 6 5 3 8 9 2
head(x,4)
[1] 6 5 3 8