framingham_c: Framingham Colesterol

Usage Examples

Usage

1

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
##---- 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 () 
{
    file.import = gfile(mensaje_excel, filter = "*.*")
    wb.datos = loadWorkbook(file.import, create = FALSE)
    misdatos.full = readWorksheet(wb.datos, sheet = 1)
    misdatos = na.omit(misdatos.full)
    coloca_reg = data.frame(row.names(misdatos))
    num_regs = dim(misdatos)[1]
    resultados = 0
    registro = 1
    for (registro in 1:num_regs) {
        sexo = misdatos[registro, 1]
        edad = misdatos[registro, 2]
        colesterol = misdatos[registro, 3]
        hdl = misdatos[registro, 4]
        tas = misdatos[registro, 5]
        tad = misdatos[registro, 6]
        fuma = misdatos[registro, 7]
        diabetes = misdatos[registro, 8]
        hipertrofia = misdatos[registro, 9]
        a <- 11.1122 - 0.9119 * log(tas) - 0.2767 * (fuma) - 
            0.7181 * log(colesterol/hdl) - 0.5865 * (hipertrofia)
        if (sexo == 0) {
            m = a - 1.4792 * log(edad) - 0.1759 * (diabetes)
        }
        if (sexo == 1) {
            m = a - 5.8549 + 1.8515 * (log(edad/74))^2 - 0.3758 * 
                (diabetes)
        }
        mu <- 4.4181 + m
        sigma = exp(-0.3155 - 0.2784 * m)
        u <- (log(10) - mu)/sigma
        p = 1 - exp(-exp(u))
        resultados[registro] = p
    }
    matriz_final = data.frame(coloca_reg, resultados)
    matriz_final2 = na.omit(matriz_final)
    posicion = dim(misdatos.full)[1]
    lista_pos = data.frame(rep(1:posicion))
    matriz_final3 = merge(lista_pos, matriz_final2, by.x = "rep.1.posicion.", 
        by.y = "row.names.misdatos.", all = "TRUE")
    wb.result = loadWorkbook(file.import, create = FALSE)
    appendWorksheet(wb.result, matriz_final3, sheet = 2, header = TRUE, 
        rownames = FALSE)
    saveWorkbook(wb.result, file.import)
    gmessage(mensaje_fin, title = "OK")
  }

cvrcalc documentation built on May 2, 2019, 4:10 p.m.