lrs: Low Risk Score

Usage Examples

Usage

1
lrs()

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
##---- 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("Selecciona el fichero Excel con los DATOS a importar", 
        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]
        s0_edad <- 0
        s0_edad10 <- 0
        if (sexo == 0) {
            s0_edad = exp(-exp(-22.1) * (edad - 20)^4.71)
            s0_edad10 = exp(-exp(-22.1) * (edad - 10)^4.71)
        }
        s0_edad
        s0_edad10
        if (sexo == 1) {
            s0_edad = exp(-exp(-29.8) * (edad - 20)^6.36)
            s0_edad10 = exp(-exp(-29.8) * (edad - 10)^6.36)
        }
        s0_edad
        s0_edad10
        w <- 0
        w = 0.24 * (0.02586 * colesterol - 6) + 0.018 * (tas - 
            120) + 0.71 * (fuma)
        s_edad <- 0
        s_edad10 <- 0
        s_edad = s0_edad^exp(w)
        s_edad
        s_edad10 = s0_edad10^exp(w)
        s_edad10
        s10_edad = s_edad10/s_edad
        s10_edad
        riesgo10_ec = 1 - s10_edad
        riesgo10_ec
        s0_edad <- 0
        s0_edad10 <- 0
        if (sexo == 0) {
            s0_edad = exp(-exp(-26.7) * (edad - 20)^5.64)
            s0_edad10 = exp(-exp(-26.7) * (edad - 10)^5.64)
        }
        s0_edad
        s0_edad10
        if (sexo == 1) {
            s0_edad = exp(-exp(-31) * (edad - 20)^6.62)
            s0_edad10 = exp(-exp(-31) * (edad - 10)^6.62)
        }
        s0_edad
        s0_edad10
        w <- 0
        w = 0.02 * (0.02586 * colesterol - 6) + 0.022 * (tas - 
            120) + 0.63 * (fuma)
        s_edad <- 0
        s_edad10 <- 0
        s_edad = s0_edad^exp(w)
        s_edad
        s_edad10 = s0_edad10^exp(w)
        s_edad10
        s10_edad = s_edad10/s_edad
        s10_edad
        riesgo10_enc = 1 - s10_edad
        riesgo10_enc
        "RIESGO TOTAL DE ENFERMEDAD CARDIOVASCULAR A 10 A?OS EN UNA POBLACI?N DE RIESGO BAJO"
        p = (riesgo10_ec + riesgo10_enc)
        p
        if (edad >= 35 && edad <= 64) 
            resultados[registro] = p
        else resultados[registro] = NA
    }
    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("Proceso concluido", title = "OK")
  }

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