probability.check {ArvoRe} | R Documentation |
~~ A concise (1-5 lines) description of what the function does. ~~
probability.check(k)
k |
~~Describe k here~~ |
~~ If necessary, more details than the description above ~~
~Describe the value returned If it is a LIST, use
comp1 |
Description of 'comp1' |
comp2 |
Description of 'comp2' |
...
....
~~further notes~~
~Make other sections like Warning with section{Warning }{....} ~
~~who you are~~
~put references to the literature/web site here ~
~~objects to See Also as help
, ~~~
##---- Should be DIRECTLY executable !! ---- ##-- ==> Define data, use random, ##-- or do help(data=index) for the standard data sets. ## The function is currently defined as function(k) { names(k) <- c("Level", "Node.N", "Node.name", "Father", "Father.Name", "Prob", "Type", "Note", "Destiny", "Payoff1", "Payoff2") Levels <- 2:max(k$Level) variables <- names(k) ans <- "" for (i in Levels) { Data <- subset(k, Level == i, select = variables) nodes <- as.numeric(names(table(Data$Father))) for (j in nodes) { Data2 <- subset(Data, Father == j, select = variables) psum <- sum(Data2$Prob) if (psum != 1) { nome.pai <- Data2$Father.Name[1] ans <- paste(ans, "Há problema em [ NÍVEL = ", i-1, ", NODO = ", nome.pai, " ] \n", sep = "") } } } ans2 <- "1" if (nchar(ans) == 0) { ans <- "As probabilidades somam 1. Tudo ok!" ans2 <- "0" } return(c(ans,ans2)) }