Ey! I am trying to make here an iterative execution of t.test
A little bit of my code is like
structure(list(paciente = structure(c(6186, 6350, 6506, 6488,
6196), label = "Paciente", format.spss = "F6.0"), sexo_s1 = structure(c(2L,
1L, 2L, 2L, 1L), .Label = c("Hombre", "Mujer"), label = "Sexo", class = "factor"),
edad_s1 = structure(c(66, 63, 69, 62, 63), label = "Edad", format.spss = "F3.0"),
grupo_int_v00 = structure(c(1L, 2L, 1L, 1L, 1L), .Label = c("A",
"B"), label = "Grupo de intervención", class = "factor"),
peso1_v00 = structure(c(69.5, 88.2, 75.2, 62, 95.8), label = "Peso: 1a determinación", format.spss = "F5.1"),
cintura1_v00 = structure(c(101.5, 106, 110.2, 90, 121), label = "Cintura: 1a determinación", format.spss = "F5.1"),
tasis2_e_v00 = structure(c(146, 144, 146, 132, 117), label = "TA: tensión arterial 2: sistólica", format.spss = "F4.0"),
tadias2_e_v00 = structure(c(60, 76, 60, 58, 70), label = "TA: tensión arterial 2: diastólica", format.spss = "F4.0"),
p17_total_v00 = structure(c(9, 10, 9, 9, 6), label = "Cuestionario de 17 puntos: Suma de puntuación de P17", format.spss = "F3.0"),
geaf_tot_v00 = structure(c(559.44, 5734.27, 1153.85, 3524.48,
783.22), label = "AF: Gasto energético en actividad física total (MET•min/sem)", format.spss = "F8.2"),
glucosa_v00 = structure(c(87, 99, 98, 97, 113), label = "Analítica: Glucosa en mg/dL", format.spss = "F4.0"),
albumi_v00 = structure(c(5.29, 4.88, 4.49, 4.68, 4.91), label = "Analítica: Albúmina en g/dL", format.spss = "F6.2"),
coltot_v00 = structure(c(320, 180, 309, 253, 159), label = "Analítica: Colesterol total en mg/dL", format.spss = "F4.0"),
hdl_v00 = structure(c(72, 42, 69, 64, 59), label = "Analítica: Colesterol HDL en mg/dL", format.spss = "F4.0"),
ldl_calc_v00 = structure(c(191, 124, 213, 150, 86), label = "Analítica: LDL calculado en mg/dL si trigli<=300", format.spss = "F4.0"),
trigli_v00 = structure(c(284, 70, 135, 195, 72), label = "Analítica: Triglicéridos en mg/dL", format.spss = "F5.0"),
hba1c_v00 = structure(c(5.77, 5.21, 5.72, 5.66, 5.75), label = "Analítica: Hemoglobina glicosilada (HbA1c %)", format.spss = "F5.2"),
peso1_v66 = structure(c(64.5, 68, 75, 60, 95), label = "Peso: 1a determinación", format.spss = "F5.1"),
cintura1_v66 = structure(c(97, 87.5, 110, 88, 119), label = "Cintura: 1a determinación", format.spss = "F5.1"),
tasis2_e_v66 = structure(c(140, 104, 130, 136, 140), label = "TA: tensión arterial 2: sistólica", format.spss = "F4.0"),
tadias2_e_v66 = structure(c(70, 48, 61, 71, 94), label = "TA: tensión arterial 2: diastólica", format.spss = "F4.0", display_width = 13L),
p17_total_v66 = structure(c(13, 13, 13, 15, 11), label = "Cuestionario de 17 puntos: Suma total de P17", format.spss = "F3.0"),
geaf_tot_v66 = structure(c(1286.71, 4510.49, 1958.04, 1370.63,
5510.49), label = "AF: Gasto energético en actividad física total (MET•min/sem)", format.spss = "F8.2"),
glucosa_v66 = structure(c(87, 89, 98, 97, 121), label = "Analítica: Glucosa en mg/dL", format.spss = "F4.0"),
albumi_v66 = structure(c(4.62, 4.64, 4.56, 4.93, 4.62), label = "Analítica: Albúmina en g/dL", format.spss = "F6.2"),
coltot_v66 = structure(c(301, 182, 227, 252, 188), label = "Analítica: Colesterol total en mg/dL", format.spss = "F4.0"),
hdl_v66 = structure(c(61, 53, 69, 78, 49), label = "Analítica: Colesterol HDL en mg/dL", format.spss = "F4.0"),
ldl_calc_v66 = structure(c(201, 119, 135, 146, 120), label = "Analítica: LDL calculado en mg/dL si trigli<=300", format.spss = "F4.0"),
trigli_v66 = structure(c(194, 50, 113, 141, 97), label = "Analítica: Triglicéridos en mg/dL", format.spss = "F5.0"),
hba1c_v66 = structure(c(5.64, 4.78, 5.66, 5.31, 5.85), label = "Analítica: Hemoglobina glicosilada (HbA1c %)", format.spss = "F5.2"),
peso1_v01 = structure(c(67.7, 70.2, 72, 59.5, 94), label = "Peso: 1a determinación", format.spss = "F5.1"),
cintura1_v01 = structure(c(99, 90.5, 106.5, 88, 119), label = "Cintura: 1a determinación", format.spss = "F5.1"),
tasis2_e_v01 = structure(c(146, 109, 148, 122, 123), label = "TA: tensión arterial 2: sistólica", format.spss = "F4.0"),
tadias2_e_v01 = structure(c(64, 51, 77, 56, 72), label = "TA: tensión arterial 2: diastólica", format.spss = "F4.0"),
p17_total_v01 = structure(c(11, 15, 7, 13, 9), label = "Cuestionario de 17 puntos: Suma total de P17", format.spss = "F3.0"),
geaf_tot_v01 = structure(c(1398.6, 6608.39, 3356.64, 3454.55,
3412.59), label = "AF: Gasto energético en actividad física total (MET•min/sem)", format.spss = "F8.2"),
glucosa_v01 = structure(c(93, 91, 98, 93, 115), label = "Analítica: Glucosa en mg/dL", format.spss = "F4.0"),
albumi_v01 = structure(c(5.05, 4.66, 4.32, 4.7, 5.09), label = "Analítica: Albúmina en g/dL", format.spss = "F6.2"),
coltot_v01 = structure(c(287, 182, 278, 215, 182), label = "Analítica: Colesterol total en mg/dL", format.spss = "F4.0"),
hdl_v01 = structure(c(67, 53, 75, 59, 57), label = "Analítica: Colesterol HDL en mg/dL", format.spss = "F4.0"),
ldl_calc_v01 = structure(c(170, 118, 184, 123, 108), label = "Analítica: LDL calculado en mg/dL si trigli<=300", format.spss = "F4.0"),
trigli_v01 = structure(c(248, 56, 94, 166, 84), label = "Analítica: Triglicéridos en mg/dL", format.spss = "F5.0"),
hba1c_v01 = structure(c(6.14, 4.85, 5.57, 5.35, 5.61), label = "Analítica: Hemoglobina glicosilada (HbA1c %)", format.spss = "F5.2"),
i_hucpeptide_v00 = structure(c(1048.46, 1044.93, 298.31,
673.5, 831.56), label = "Hu C-peptide (72) IMIM S'han substituit en les següents var els codis de inf i sup a limit de detecció per el limit inf i sup de detecció", format.spss = "F9.2", display_width = 13L),
i_hucpeptide_v66 = structure(c(1213.33, 415.69, 410.66, 444.87,
1112.99), label = "Hu C-peptide (72) IMIM", format.spss = "F9.2", display_width = 13L),
i_hucpeptide_v01 = structure(c(1104.46, 508.5, 314.53, 691.18,
1087.8), label = "Hu C-peptide (72) IMIM", format.spss = "F9.2", display_width = 12L),
i_hughrelin_v00 = structure(c(1181.43, 1368.86, 984.2, 1230.06,
310.49), label = "Hu Ghrelin (26) IMIM", format.spss = "F7.2", display_width = 10L),
i_hughrelin_v66 = structure(c(1276.53, 1233.11, 914.69, 1047.39,
1627.78), label = "Hu Ghrelin (26) IMIM", format.spss = "F7.2", display_width = 13L),
i_hughrelin_v01 = structure(c(1355.59, 1384.61, 1101.59,
977.03, 1326.07), label = "Hu Ghrelin (26) IMIM", format.spss = "F7.2", display_width = 11L),
i_hugip_v00 = structure(c(2.67, 2.67, 2.67, 2.67, 2.67), label = "Hu GIP (14) IMIM", format.spss = "F9.2", display_width = 9L),
i_hugip_v66 = structure(c(2.67, 2.67, 2.67, 2.67, 2.67), label = "Hu GIP (14) IMIM", format.spss = "F9.2", display_width = 9L),
i_hugip_v01 = structure(c(2.67, 2.67, 2.67, 2.67, 2.67), label = "Hu GIP (14) IMIM", format.spss = "F9.2", display_width = 9L),
i_huglp1_v00 = structure(c(237.7, 80.69, 119.73, 138.32,
267.46), label = "Hu GLP-1 (27) IMIM", format.spss = "F9.2", display_width = 9L),
i_huglp1_v66 = structure(c(208.08, 146.6, 148.86, 174.06,
271.76), label = "Hu GLP-1 (27) IMIM", format.spss = "F9.2", display_width = 9L),
i_huglp1_v01 = structure(c(171.47, 14.14, 65.09, 30.88, 125.02
), label = "Hu GLP-1 (27) IMIM", format.spss = "F9.2", display_width = 9L),
i_huglucagon_v00 = structure(c(505.47, 330.99, 490.17, 357.35,
450.59), label = "Hu Glucagon (15) IMIM", format.spss = "F9.2", display_width = 11L),
i_huglucagon_v66 = structure(c(467.9, 256.56, 413.85, 296.98,
267.4), label = "Hu Glucagon (15) IMIM", format.spss = "F9.2", display_width = 11L),
i_huglucagon_v01 = structure(c(456.84, 114.98, 469.21, 328.99,
150.44), label = "Hu Glucagon (15) IMIM", format.spss = "F9.2", display_width = 9L),
i_huinsulin_v00 = structure(c(59.2, 220.13, 69.4, 229.06,
260.97), label = "Hu Insulin (12) IMIM", format.spss = "F7.2", display_width = 10L),
i_huinsulin_v66 = structure(c(86.05, 67.66, 89.7, 137.13,
258.68), label = "Hu Insulin (12) IMIM", format.spss = "F7.2", display_width = 9L),
i_huinsulin_v01 = structure(c(115.98, 125.24, 58.99, 191.92,
322.21), label = "Hu Insulin (12) IMIM", format.spss = "F7.2"),
i_huleptin_v00 = structure(c(12527.83, 6062.53, 6870.45,
5211.27, 4770.77), label = "Hu Leptin (78) IMIM", format.spss = "F9.2", display_width = 9L),
i_huleptin_v66 = structure(c(12385.23, 1639.01, 6758.47,
4239.06, 4232.78), label = "Hu Leptin (78) IMIM", format.spss = "F9.2", display_width = 9L),
i_huleptin_v01 = structure(c(7888.05, 1647.15, 7571.15, 5228.87,
4668.29), label = "Hu Leptin (78) IMIM", format.spss = "F9.2", display_width = 9L),
i_hupai1_v00 = structure(c(2310.43, 3063.68, 1894.16, 1977.9,
1956.2), label = "Hu PAI-1 (61) IMIM", format.spss = "F7.2"),
i_hupai1_v66 = structure(c(1979.89, 1448, 2103.56, 1807.18,
1860.22), label = "Hu PAI-1 (61) IMIM", format.spss = "F7.2"),
i_hupai1_v01 = structure(c(2792.96, 1972.73, 2061.57, 2057.72,
2993.61), label = "Hu PAI-1 (61) IMIM", format.spss = "F7.2"),
i_huresistin_v00 = structure(c(4320.48, 3879.15, 2512.8,
2676.05, 3231.03), label = "Hu Resistin (65) IMIM", format.spss = "F8.2", display_width = 9L),
i_huresistin_v66 = structure(c(3939.64, 3859.42, 4229.36,
2996.14, 7468.58), label = "Hu Resistin (65) IMIM", format.spss = "F8.2", display_width = 7L),
i_huresistin_v01 = structure(c(5001.66, 4246.83, 2866.02,
3101.51, 9205.19), label = "Hu Resistin (65) IMIM", format.spss = "F8.2", display_width = 6L),
i_huvisfatin_v00 = structure(c(1427.42, 556.99, 1564.33,
649.45, 559.34), label = "Hu Visfatin (22) IMIM", format.spss = "F9.2", display_width = 6L),
i_huvisfatin_v66 = structure(c(1491.88, 8.64, 1333.86, 261.82,
8.64), label = "Hu Visfatin (22) IMIM", format.spss = "F9.2", display_width = 6L),
i_huvisfatin_v01 = structure(c(968.09, 8.64, 1791.18, 264.15,
102.84), label = "Hu Visfatin (22) IMIM", format.spss = "F9.2", display_width = 10L),
col_rema_v00 = structure(c(57, 14, 27, 39, 14), format.spss = "F8.2", display_width = 14L),
col_rema_v66 = structure(c(39, 10, 23, 28, 19), format.spss = "F8.2", display_width = 14L),
col_rema_v01 = structure(c(50, 11, 19, 33, 17), format.spss = "F8.2", display_width = 14L),
homa_v00 = structure(c(228.906666666667, 968.572, 302.275555555556,
987.503111111111, 1310.64933333333), format.spss = "F8.2", display_width = 10L),
homa_v66 = structure(c(332.726666666667, 267.632888888889,
390.693333333333, 591.182666666667, 1391.12355555556), format.spss = "F8.2", display_width = 10L),
homa_v01 = structure(c(479.384, 506.526222222222, 256.934222222222,
793.269333333333, 1646.85111111111), format.spss = "F8.2", display_width = 10L),
i_pcr_v00 = structure(c(0.31, 0.22, 0.24, NA, 0.13), label = "25 lab imim: Proteína C reactiva en mg/dL", format.spss = "F5.2"),
i_pcr_v66 = structure(c(1.3, 0.07, 0.23, 0.15, 0.38), label = "25 lab imim: Proteína C reactiva en mg/dL", format.spss = "F4.2"),
i_pcr_v01 = structure(c(0.35, 0.07, 0.49, 0.76, 0.1), label = "25 lab imim: Proteína C reactiva en mg/dL", format.spss = "F4.2"),
d_homa_v66 = structure(c(103.82, -700.939111111111, 88.4177777777778,
-396.320444444445, 80.4742222222221), format.spss = "F8.2", display_width = 12L),
d_homa_v01 = structure(c(250.477333333333, -462.045777777778,
-45.3413333333334, -194.233777777778, 336.201777777777), format.spss = "F8.2", display_width = 12L),
d_hughrelin_v66 = structure(c(95.0999999999999, -135.75,
-69.51, -182.67, 1317.29), format.spss = "F8.2", display_width = 18L),
d_hughrelin_v01 = structure(c(174.16, 15.75, 117.39, -253.03,
1015.58), format.spss = "F8.2", display_width = 18L), d_huinsulin_v66 = structure(c(26.85,
-152.47, 20.3, -91.93, -2.29000000000002), format.spss = "F8.2", display_width = 17L),
d_huinsulin_v01 = structure(c(56.78, -94.89, -10.41, -37.14,
61.24), format.spss = "F8.2", display_width = 17L), d_hucpeptide_v66 = structure(c(164.87,
-629.24, 112.35, -228.63, 281.43), format.spss = "F8.2", display_width = 18L),
d_hucpeptide_v01 = structure(c(56, -536.43, 16.22, 17.6799999999999,
256.24), format.spss = "F8.2", display_width = 18L), d_huglucagon_v66 = structure(c(-37.5700000000001,
-74.43, -76.32, -60.37, -183.19), format.spss = "F8.2", display_width = 18L),
d_huglucagon_v01 = structure(c(-48.6300000000001, -216.01,
-20.96, -28.36, -300.15), format.spss = "F8.2", display_width = 18L),
d_huleptin_v66 = structure(c(-142.6, -4423.52, -111.98, -972.21,
-537.990000000001), format.spss = "F8.2", display_width = 16L),
d_huleptin_v01 = structure(c(-4639.78, -4415.38, 700.7, 17.5999999999995,
-102.48), format.spss = "F8.2", display_width = 16L), d_huresistin_v66 = structure(c(-380.84,
-19.73, 1716.56, 320.09, 4237.55), format.spss = "F8.2", display_width = 18L),
d_huresistin_v01 = structure(c(681.18, 367.68, 353.22, 425.46,
5974.16), format.spss = "F8.2", display_width = 18L), d_huvisfatin_v66 = structure(c(64.46,
-548.35, -230.47, -387.63, -550.7), format.spss = "F8.2", display_width = 18L),
d_huvisfatin_v01 = structure(c(-459.33, -548.35, 226.85,
-385.3, -456.5), format.spss = "F8.2", display_width = 18L),
d_glucosa_v66 = structure(c(0, -10, 0, 0, 8), format.spss = "F8.2", display_width = 15L),
d_glucosa_v01 = structure(c(6, -8, 0, -4, 2), format.spss = "F8.2", display_width = 15L),
d_coltot_v66 = structure(c(-19, 2, -82, -1, 29), format.spss = "F8.2", display_width = 14L),
d_coltot_v01 = structure(c(-33, 2, -31, -38, 23), format.spss = "F8.2", display_width = 14L),
d_hdl_v66 = structure(c(-11, 11, 0, 14, -10), format.spss = "F8.2", display_width = 11L),
d_hdl_v01 = structure(c(-5, 11, 6, -5, -2), format.spss = "F8.2", display_width = 11L),
d_ldl_calc_v66 = structure(c(10, -5, -78, -4, 34), format.spss = "F8.2", display_width = 16L),
d_ldl_calc_v01 = structure(c(-21, -6, -29, -27, 22), format.spss = "F8.2", display_width = 16L),
d_col_rema_v66 = structure(c(-18, -4, -4, -11, 5), format.spss = "F8.2", display_width = 16L),
d_col_rema_v01 = structure(c(-7, -3, -8, -6, 3), format.spss = "F8.2", display_width = 16L),
d_trigli_v66 = structure(c(-90, -20, -22, -54, 25), format.spss = "F8.2", display_width = 14L),
d_trigli_v01 = structure(c(-36, -14, -41, -29, 12), format.spss = "F8.2", display_width = 14L),
d_hba1c_v66 = structure(c(-0.13, -0.43, -0.0599999999999996,
-0.350000000000001, 0.0999999999999996), format.spss = "F8.2", display_width = 13L),
d_hba1c_v01 = structure(c(0.37, -0.36, -0.149999999999999,
-0.31, -0.14), format.spss = "F8.2", display_width = 13L),
d_tasis2_e_v66 = structure(c(-6, -40, -16, 4, 23), format.spss = "F8.2", display_width = 16L),
d_tasis2_e_v01 = structure(c(0, -35, 2, -10, 6), format.spss = "F8.2", display_width = 16L),
d_tadias2_e_v66 = structure(c(10, -28, 1, 13, 24), format.spss = "F8.2", display_width = 17L),
d_tadias2_e_v01 = structure(c(4, -25, 17, -2, 2), format.spss = "F8.2", display_width = 17L),
d_peso1_v66 = structure(c(-5, -20.2, -0.200000000000003,
-2, -0.799999999999997), format.spss = "F8.2", display_width = 13L),
d_peso1_v01 = structure(c(-1.8, -18, -3.2, -2.5, -1.8), format.spss = "F8.2", display_width = 13L),
d_cintura1_v66 = structure(c(-4.5, -18.5, -0.200000000000003,
-2, -2), format.spss = "F8.2", display_width = 16L), d_cintura1_v01 = structure(c(-2.5,
-15.5, -3.7, -2, -2), format.spss = "F8.2", display_width = 16L),
d_geaf_tot_v66 = structure(c(727.27, -1223.78, 804.19, -2153.85,
4727.27), format.spss = "F8.2", display_width = 16L), d_geaf_tot_v01 = structure(c(839.16,
874.12, 2202.79, -69.9299999999998, 2629.37), format.spss = "F8.2", display_width = 16L),
d_p17_total_v66 = structure(c(4, 3, 4, 6, 5), format.spss = "F8.2", display_width = 11L),
d_p17_total_v01 = structure(c(2, 5, -2, 4, 3), format.spss = "F8.2"),
d_hupai1_v66 = structure(c(-330.54, -1615.68, 209.4, -170.72,
-95.98), format.spss = "F8.2", display_width = 13L), d_hupai1_v01 = structure(c(482.53,
-1090.95, 167.41, 79.8199999999997, 1037.41), format.spss = "F8.2", display_width = 13L),
d_hugip_v66 = structure(c(0, 0, 0, 0, 0), format.spss = "F8.2", display_width = 13L),
d_hugip_v01 = structure(c(0, 0, 0, 0, 0), format.spss = "F8.2", display_width = 13L),
d_huglp1_v66 = structure(c(-29.62, 65.91, 29.13, 35.74, 4.30000000000001
), format.spss = "F8.2", display_width = 13L), d_huglp1_v01 = structure(c(-66.23,
-66.55, -54.64, -107.44, -142.44), format.spss = "F8.2", display_width = 13L),
d_pcr_v66 = structure(c(0.99, -0.15, -0.00999999999999998,
NA, 0.25), format.spss = "F8.2"), d_pcr_v01 = structure(c(0.04,
-0.15, 0.25, NA, -0.03), format.spss = "F8.2"), ln_trigli_v00 = structure(c(5.64897423816121,
4.24849524204936, 4.90527477843843, 5.27299955856375, 4.27666611901606
), format.spss = "F8.2", display_width = 15L), ln_trigli_v66 = structure(c(5.26785815906333,
3.91202300542815, 4.72738781871234, 4.94875989037817, 4.57471097850338
), format.spss = "F8.2", display_width = 15L), ln_trigli_v01 = structure(c(5.51342874616498,
4.02535169073515, 4.54329478227, 5.11198778835654, 4.43081679884331
), format.spss = "F8.2", display_width = 15L), ln_homa_v00 = structure(c(5.43331435133417,
6.87582282184946, 5.71133903697296, 6.89517964726258, 7.17827796768953
), format.spss = "F8.2", display_width = 13L), ln_homa_v66 = structure(c(5.80732133210176,
5.58961622387433, 5.96792293852495, 6.38212505030477, 7.23786701296476
), format.spss = "F8.2", display_width = 13L), ln_homa_v01 = structure(c(6.17250194639118,
6.22757609376468, 5.54882010747518, 6.67616280247432, 7.40662032603734
), format.spss = "F8.2", display_width = 13L), ln_hba1c_v00 = structure(c(1.75267208052001,
1.65057985576528, 1.74396880539171, 1.73342389221509, 1.74919985480926
), format.spss = "F8.2", display_width = 14L), ln_hba1c_v66 = structure(c(1.72988406550997,
1.56444054650336, 1.73342389221509, 1.66959183525385, 1.76644166124377
), format.spss = "F8.2", display_width = 14L), ln_hba1c_v01 = structure(c(1.81482474215905,
1.57897870494939, 1.71739505393919, 1.67709656090792, 1.72455071953461
), format.spss = "F8.2", display_width = 14L), ln_geaf_tot_v00 = structure(c(6.32693628339561,
8.65421573288269, 7.05085945595059, 8.16748818663406, 6.66341362715175
), format.spss = "F8.2", display_width = 17L), ln_geaf_tot_v66 = structure(c(7.15984385198013,
8.41416107404513, 7.57969925189098, 7.22302576713632, 8.61440882741259
), format.spss = "F8.2", display_width = 17L), ln_geaf_tot_v01 = structure(c(7.24322701526977,
8.7960953328297, 8.11869575262367, 8.14744748169876, 8.13522681277181
), format.spss = "F8.2", display_width = 17L), i_ratiolg_v00 = structure(c(10.6039545296801,
4.42888973306255, 6.98074578337736, 4.23659821472123, 15.3652935682309
), format.spss = "F8.2"), i_ratiolg_v66 = structure(c(9.70226316655308,
1.32916771415364, 7.38880932337732, 4.04726033282731, 2.60033911216503
), format.spss = "F8.2"), i_ratiolg_v01 = structure(c(5.81890542125569,
1.18961295960595, 6.87292912971251, 5.35180086588948, 3.52039485095055
), format.spss = "F8.2")), row.names = c(NA, -5L), class = c("tbl_df",
"tbl", "data.frame"))
Now I have created a loop to iterate a lot. The problem is just with t.test. I have 2 categorys for the variable grupo_int_v00 --> A or B
Old syntax
P1 <- t.test(x=dat[,v[1]], y=dat[,v[2]], paired = TRUE)$p.value
New syntax
P1 <- t.test(subset(dat, grupo_int_v00 == "A")[,v[1]], subset(dat, grupo_int_v00 == "A")[,v[2]], paired = TRUE)$p.value #v00 vs v66
Error: Must subset columns with a valid subscript vector.
i Logical subscripts must match the size of the indexed input.
x Input has size 1 but subscript yok
has size 206.
The object v is defined in the loop
i=1
tab <- NA
for(i in 1:length(rowvars)){
#For each variable in 'rowvars', writes the corresponding to each visit.
#eg: "p17_total_v00","p17_total_v66","d_p17_total_v66","p17_total_v01","d_p17_total_v01"
#eg: "i_hugip_v00","i_hugip_v66","d_hugip_v66","i_hugip_v01","d_hugip_v01"
v <- paste0(rowvars[i], visit)
v[c(3,5)] <- paste0("d_", v[c(3,5)])
v <- sub("d_i_", "d_", v)
The idea is compare patients belonging to groups of intervention, but with-in subject time comparison, that is, subject1time0 vs subject1time1 ....
The proble is the damn square brackets, the syntax to make them work is so different between functions. I followed the same dynamic for other functions and totally worked
MEANsI <- sapply(subset(dat, grupo_int_v00 == "A")[,v], mean, na.rm = TRUE)
Thanks in advance