Skip to content

Instantly share code, notes, and snippets.

@mgechev
Created March 8, 2011 10:54
Show Gist options
  • Save mgechev/860140 to your computer and use it in GitHub Desktop.
Save mgechev/860140 to your computer and use it in GitHub Desktop.
Statistics - 01.03.2011
typos.draft1 = c(2,3,0,3,1,0,0,1)
typos.draft2 = c(0,3,0,3,1,0,0,1)
typos.draft2 = typos.draft1
typos.draft2
typos.draft2[1] = 0
typos.draft2
typos.draft2[2]
typos.draft2[-3] #printing the vector without it's third element
typos.draft2[c(2,4,5,8)]
typos=c(2,3,0,3,1,0,0,1)
typos
mean(typos)
median(typos)
typos2 = typos
#dispersion
for (k in 1:length(typos)) {
typos[k] = (typos[k] - mean(typos2))*(typos[k] - mean(typos2))
}
sum(typos)*(1/(length(typos) - 1))
#and easier way...
var(typos2)
myVector = c(74,122,235,111,292,111,211,133,156,79)
mean(myVector)
median(myVector)
var(myVector)
myVector[-5]
myVector[-3]
for (u in 1:length(myVector)) {
if (myVector[u] > 150) {
print(myVector[u])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment