Skip to content

Instantly share code, notes, and snippets.

View leoschet's full-sized avatar
🌴

Leonardo Schettini leoschet

🌴
View GitHub Profile
@leoschet
leoschet / mode
Last active August 29, 2015 14:04
R code (mode calculator).
# author: ljsa @ cin.ufpe.br
# dataset = vector of numbers
mode = function (dataset) {
dataset = sort(dataset);
maxTam = 1;
curTam = 0;
counter = 2;
lastMode = dataset[1];
@leoschet
leoschet / testeHipotese
Last active August 29, 2015 14:04
R code
# author: ljsa @ cin.ufpe.br
# two decimal places
decimal = function (number){
return(format(round(number, 2), nsmall = 2));
}
# cast function
character = function (text){
return(as.character(decimal(text)));
@leoschet
leoschet / plotNorm
Last active August 29, 2015 14:04
R code
# author: ljsa @ cin.ufpe.br
# sd = Standart deviation
# confidence = (0~1)
# Obj: ver se o estado esta dentro da area de confianca da media
plotNorm = function(mean, sd, confidence){
curve (dnorm(x, mean, sd), xlim = c(mean - (3*sd), mean + (3*sd)));
left = (1-confidence)/2;
right = confidence + L;