R Basic
url = https://sites/data.txt
"data.txt" is
***************
"x" "y" "z"
"1" 0.1 35 2030
"2" 0.2 38 182
"3" 0.3 123 23
... ... ... ...
***************
data_frame = read.table("url")
load(url("https:// .../*.Rdata"))
dim(data_frame)
names(data_frame)
data_frame$variable_name
plot(data_frame$x,data_frame$y)
plot(data_frame$x,data_frame$y,type="l")
mean(data$x)
median(data$x)
var(data$x)
sd(data$x) # standard deviation
summary(data$x) # returns min 1st-quarter median mean 3rd-quarter max
table(data$x) # count number of entries
barplot(table(data$x))
table(data$x,data$y) # 2D matrix
mosaicplot(table(data$x,data$y))
data[m,n] # mth observation and nth variable
data[i:j,] # ith-jth rows and all columns
data$x[m]
subset(data,data$x == "female")
subset(data,data$y > 20)
boxplot(data$x)
boxplot(data$x ~ data$y) # plot x as a function of y or x versus y
hist(data$x,breaks = 100) # breaks controls the number of bins
outcomes = c("heads", "tails")
sample(outcomes, size=1, replace=TRUE) # fair game by default
sample(outcomes, size=100, replace=TRUE,prob=c(0.3,0.7)) # assign probability to outcomes
sample(data$x,100) # sample 100 individuals from population data$x
pnorm(35,mean=30,sd=5) # what percentile of 35 in Norm(30,5); error function
qnorm(0.9,30,5) # what cut off value for percentile 90% in Norm(30,5)
choose(n,k) # combination number n!/k!(n-k)!
dbinom(k,n,p) # binomial distribution
sum(dbinom(k:k+m,n,p))