1/20
Looks like no tags are added yet.
random sample generation
sample(min value: max value, number of values, replace=FALSE or TRUE)
vector/list
c(1,2,3,4,5
how does vector/list become usable data
data =c(1,2,3,4,5)
frequency table
freq_table=table(data)
print(freq_table)
how to make frequency table with bins
d=sample(1:100, 1000, replace=T)
bins=seq(0,100,by=10)
cut_data=cut(d,bins)
table(cut_data)
cumulative frequency table
cumsum(table(data))
bar graph
barplot(f,names.arg=x,ylim=c(0,10), col=”blue”,xlab=”Number”,ylab=”frequency”,main=”Title”
histogram
hist(d,breaks=20,main=”Random Numbers,”col=”red”,xlim=c(0,100), xlab=”Number”
scatter plot
x=c(1,2,3,4,5)
y=c(2,3,4,5)
plot(x,y)
standard deviation
sd(x)
mode
get_mode=function{ux=unique(x),ux[which.max(tabulate(match9x,ux)))]
boxplot
boxplot(x,y,col=c(‘red’,’blue’))
binomial distribution
dibinom(events,trials,probability of success)
poisson distribution
dpois(x,u)
chi squared
observed=c(1,2,3,4,5)
expected=c(1/6,1/6/,1/6,1/6,1/6)
chisq.test(x=observed,p=expected,correct=FALSE/TRUE)
matrix
matrix(c(10,20,30,40),nrow=2)
fischer probability
fisher.text(x,alternative=”greater”) altternative only necessary if examining one side of the calculation
t distribution
qt(a,df,lower.tail=FALSE)
one sided critical value t distribution
qt(a/2,df,lower.tail=FALSE)
t-test
t.test(x,mu=u0)
paired t test
t.test(x,y,paired=TRUE)