Last active
December 22, 2015 20:09
-
-
Save andilabs/6524859 to your computer and use it in GitHub Desktop.
adamw classifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
adamw_classifier<-function(lista){ | |
# co najmniej 2 oceny=5 -> strona trafia do klasy HC (Highly Credibly) | |
# co najmniej 2 oceny=4 -> strona trafia do klasy N (Neutral) | |
# co najmniej 2 oceny<4 -> strona trafia do klasy HNC (Highly Not Credible) | |
print(lista) | |
for (i in 1:length(lista)){ | |
lista[i]=notna(lista[i]) | |
} | |
print(lista) | |
df<-data.frame(table(lista)) | |
print (df) | |
iclass="" | |
# list Freq | |
if ((5 %in% df$lista) && (df[df$lista==5,]$Freq >= 2)) { | |
# iclass="HC" | |
print("HC was assigned") | |
return (as.character("HC")) | |
} | |
# else{ | |
# break | |
# } | |
else if ((4 %in% df$lista) && (df[df$lista==4,]$Freq >= 2)){ | |
# iclass="N" | |
print("N was assigned") | |
return (as.character("N")) | |
#break | |
} | |
# else{ | |
# break | |
# } | |
# else if (nrow(df)>=3){ | |
else if (sum(df[as.numeric(levels(df$lista)[df$lista]) < 4,]$Freq) >=2){ | |
print("HNC was assigned") | |
return (as.character("HNC")) | |
} | |
# } | |
else{ | |
# iclass="UNDIFINED" | |
print("UNDIFINED was assigned") | |
return (as.character("UNDIFINED")) | |
} | |
# print(iclass) | |
#return (as.character(iclass)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment