Paquete flextable
Hay diversos paquetes en R para elaborar tablas. En este tutorial uso el paquete
flextable
Emplearé las siguiente variables:
- Empleo y area de empleo
- Ocupación según sexo. Jefes de familia
- Ocupación según sexo. Segundo miembro
- Crosstabulación de ambos tipos de ocupaciones
use_df_printer()
set_flextable_defaults(
theme_fun = theme_booktabs,
big.mark = ".",
decimal.mark = ",",
font.color = "#666666",
border.color = "#666666",
padding = 3,
digits = 2
)
# jefe de familia. # trabaja o estudia actualmente
miembros_ocupacion %>%
group_by(sexo) %>%
count(trabaja_o_estudia_actualmente) %>%
na.omit() %>%
mutate(proporcion = n/sum(n)*100,
proporcion = round(proporcion, 2)) %>%
select(Sexo = sexo,
"Trabaja o estudia actualmente" = trabaja_o_estudia_actualmente,
n = n, "%" = proporcion ) %>%
flextable() |> # transformo en tabla flex
theme_booktabs(bold_header = TRUE)|> # negritas en el encabezamiento
autofit() |>
merge_v(j = 1) |>
valign(j = 1, valign = "top")|>
align(align = "center", part = "all", j = 2:4)
Warning: 'big.mark' and 'decimal.mark' are both '.', which could be confusing
Sexo | Trabaja o estudia actualmente | n | % |
FEMENINO | NI TRABAJA NI ESTUDIA | 1 | 2,38 |
TRABAJA | 36 | 85,71 | |
TRABAJA Y ESTUDIA | 5 | 11,90 | |
MASCULINO | NI TRABAJA NI ESTUDIA | 1 | 1,52 |
TRABAJA | 63 | 95,45 | |
TRABAJA Y ESTUDIA | 2 | 3,03 |
# analizo el empleo de los segundos miembros
relacion_con_jefes %>%
group_by(sexo) %>%
count(empleo) %>%
na.omit() %>%
mutate(proporcion = n/sum(n),
proporcion = round(proporcion, 2)) %>%
ggplot() +
geom_col(
mapping = aes(
x = proporcion, # show pre-calculated proportion values
y = empleo, # reverse level order so missing/other at bottom
fill = sexo), # stacked by outcome
width = 0.8)+ # thinner bars (out of 1)
# inicio con tufte
theme_tufte() + # Minimal theme
theme(legend.position = "bottom",
axis.title = element_text(size = rel(0.8),
face = "bold.italic"),
# textos en los ejes
axis.text = element_text(
size = rel(0.8)),
panel.grid.major.x = element_line(color = "#eeeeee"),
# disminuyo el color de los sticks
axis.ticks = element_line(color = "#eeeeee")) +
scale_fill_manual(
values = c("MASCULINO" = "violetred",
"FEMENINO" = "aquamarine")) +
labs(x = "Proporción", y = "Empleo")
El 100% de los hombres trabaja de forma exclusiva, en tanto que el 50% de las muejres trabaan con exclusividad
# segundo miembro. trabaja o estudia actualmente
relacion_con_jefes %>%
group_by(sexo) %>%
count(empleo) %>%
na.omit() %>%
mutate(proporcion = n/sum(n),
proporcion = round(proporcion, 2))%>%
select(Sexo = sexo,
"Trabaja o estudia actualmente" = empleo,
n = n, "%" = proporcion ) %>%
flextable() |> # transformo en tabla flex
theme_booktabs(bold_header = TRUE)|> # negritas en el encabezamiento
autofit() |>
merge_v(j = 1) |>
valign(j = 1, valign = "top")|>
align(align = "center", part = "all", j = 3:4)
Warning: 'big.mark' and 'decimal.mark' are both '.', which could be confusing
Sexo | Trabaja o estudia actualmente | n | % |
FEMENINO | ESTUDIA | 6 | 0,11 |
NI TRABAJA NI ESTUDIA | 2 | 0,04 | |
TRABAJA | 44 | 0,81 | |
TRABAJA Y ESTUDIA | 2 | 0,04 | |
MASCULINO | TRABAJA | 9 | 1,00 |
Otras posibilidades de tabla
glimpse(sanJose_sanguineo)
Rows: 91
Columns: 25
$ `#` <dbl> 1, 2, 3, 4, 5, 6,~
$ `Apellido,Nombre` <chr> "Perez Marquina, ~
$ Identificación <chr> "VEMJUAPERM200603~
$ Sexo <chr> "M", "M", "F", "F~
$ `Fecha de Nacimiento` <chr> "09/03/2006", "28~
$ `Edad Medición` <dbl> 16.05, 16.06, 23.~
$ `Edad Actual` <dbl> 16.06, 16.07, 23.~
$ `Hemoglobina (g/dl)` <dbl> 10.5, 10.8, 10.6,~
$ `Glucosa (mg/dl)` <dbl> NA, NA, 101, 124,~
$ `Interpretación Hemoglobina` <chr> "B- Anemia modera~
$ `Hematocrito (%)` <dbl> 39, 35, 32, 39, 3~
$ `Glóbulos Blancos` <dbl> NA, NA, 8900, 720~
$ Plaquetas <dbl> 202000, 131000, 3~
$ `Triglicéridos (mg/dl)` <dbl> NA, NA, 148, 173,~
$ `Interpretación Triglicéridos` <chr> NA, NA, "Normal",~
$ `Colesterol (mg/dl)` <dbl> NA, NA, 176, 173,~
$ `Indicador Colesterol` <chr> NA, NA, "Normal",~
$ `HDL Colesterol (mg/dl)` <dbl> NA, NA, 66, 47, N~
$ `Interpretación HDL Colesterol (mg/dl)` <chr> NA, NA, "Normal",~
$ `VLDL Colesterol (mg/dl)` <dbl> NA, NA, 29, 15, N~
$ `Interpretación VLDL Colesterol` <chr> NA, NA, "Normal",~
$ `LDL Colesterol (mg/dl)` <dbl> NA, NA, 81, 111, ~
$ `Interpretación LDL Colesterol (mg/dl)` <chr> NA, NA, "Normal",~
$ Observacion <chr> NA, NA, NA, NA, N~
$ `Fecha pesquisa` <chr> "2022/08/11", "20~
flextable(sjSanguineoE)
Grupo de edades | Variable | n | Min. | Q1. | Mediana | Q3. | Max. |
5-19 | Colesterol (mg/dl) | 6 | 111.00 | 123.000 | 132.500 | 145.750 | 150.00 |
5-19 | Edad Actual | 6 | 14.05 | 17.020 | 17.060 | 17.798 | 19.08 |
5-19 | Glóbulos Blancos | 6 | 9,000.00 | 9,925.000 | 11,200.000 | 15,325.000 | 131,000.00 |
5-19 | Glucosa (mg/dl) | 6 | 90.00 | 91.750 | 96.000 | 104.000 | 108.00 |
5-19 | HDL Colesterol (mg/dl) | 6 | 47.00 | 48.000 | 48.500 | 50.500 | 59.00 |
5-19 | Hematocrito (%) | 6 | 39.00 | 41.250 | 42.500 | 46.000 | 49.00 |
5-19 | Hemoglobina (g/dl) | 6 | 11.20 | 12.550 | 13.500 | 14.075 | 14.20 |
5-19 | LDL Colesterol (mg/dl) | 6 | 49.00 | 57.500 | 62.000 | 69.500 | 85.00 |
5-19 | Plaquetas | 6 | 30,100.00 | 177,500.000 | 201,500.000 | 260,750.000 | 294,000.00 |
5-19 | Triglicéridos (mg/dl) | 6 | 62.00 | 69.750 | 79.000 | 102.500 | 153.00 |
5-19 | VLDL Colesterol (mg/dl) | 6 | 12.00 | 13.500 | 15.500 | 20.500 | 30.00 |
20+ | Colesterol (mg/dl) | 38 | 104.00 | 135.750 | 160.000 | 179.750 | 628.00 |
20+ | Edad Actual | 38 | 20.04 | 27.093 | 41.075 | 57.070 | 74.08 |
20+ | Glóbulos Blancos | 38 | 5.00 | 6,825.000 | 7,500.000 | 9,125.000 | 14,600.00 |
20+ | Glucosa (mg/dl) | 38 | 81.00 | 95.250 | 101.000 | 107.500 | 139.00 |
20+ | HDL Colesterol (mg/dl) | 38 | 38.00 | 46.000 | 49.500 | 54.750 | 66.00 |
20+ | Hematocrito (%) | 38 | 32.00 | 42.250 | 46.000 | 50.000 | 56.00 |
20+ | Hemoglobina (g/dl) | 38 | 10.60 | 12.825 | 13.550 | 14.875 | 16.20 |
20+ | LDL Colesterol (mg/dl) | 38 | 25.00 | 61.500 | 80.000 | 102.500 | 556.00 |
20+ | Plaquetas | 38 | 190.00 | 171,250.000 | 187,500.000 | 223,750.000 | 343,000.00 |
20+ | Triglicéridos (mg/dl) | 38 | 57.00 | 91.750 | 110.000 | 148.750 | 332.00 |
20+ | VLDL Colesterol (mg/dl) | 38 | 11.00 | 18.250 | 22.000 | 29.750 | 99.00 |
# demostracion
fun <- function(x) {
paste0(
c("min: ", "max: "),
formatC(range(x))
)
}
# aplica la funcion fun() a las columnas de el dataset iris
new_row <- list(
Sepal.Length = fun(iris$Sepal.Length),
Sepal.Width = fun(iris$Sepal.Width),
Petal.Width = fun(iris$Petal.Width),
Petal.Length = fun(iris$Petal.Length)
)
ft_1 <- flextable(data = head(iris))
ft_1 <- add_header(ft_1, values = new_row, top = FALSE)
ft_1 <- append_chunks(ft_1, part = "header", i = 2, )
ft_1 <- theme_booktabs(ft_1, bold_header = TRUE)
ft_1 <- align(ft_1, align = "center", part = "all")
ft_1
flextable(sjSanguineoE) -> sjSanguineoE_ft
Añado encabezado
# covierto em flextable
sjSanguineoE_ft <- add_header_row(sjSanguineoE_ft,
colwidths = c(6, 2),
values = c("", "Maximo")
) # evaluar porque me pone el primer valor en la posicion 1.
# quiero que me lo ponga en la posicion 4
Aplicación de temas
sjSanguineoE_ft %>%
theme_vanilla()
Maximo | |||||||
Grupo de edades | Variable | n | Min. | Q1. | Mediana | Q3. | Max. |
5-19 | Colesterol (mg/dl) | 6 | 111.00 | 123.000 | 132.500 | 145.750 | 150.00 |
5-19 | Edad Actual | 6 | 14.05 | 17.020 | 17.060 | 17.798 | 19.08 |
5-19 | Glóbulos Blancos | 6 | 9,000.00 | 9,925.000 | 11,200.000 | 15,325.000 | 131,000.00 |
5-19 | Glucosa (mg/dl) | 6 | 90.00 | 91.750 | 96.000 | 104.000 | 108.00 |
5-19 | HDL Colesterol (mg/dl) | 6 | 47.00 | 48.000 | 48.500 | 50.500 | 59.00 |
5-19 | Hematocrito (%) | 6 | 39.00 | 41.250 | 42.500 | 46.000 | 49.00 |
5-19 | Hemoglobina (g/dl) | 6 | 11.20 | 12.550 | 13.500 | 14.075 | 14.20 |
5-19 | LDL Colesterol (mg/dl) | 6 | 49.00 | 57.500 | 62.000 | 69.500 | 85.00 |
5-19 | Plaquetas | 6 | 30,100.00 | 177,500.000 | 201,500.000 | 260,750.000 | 294,000.00 |
5-19 | Triglicéridos (mg/dl) | 6 | 62.00 | 69.750 | 79.000 | 102.500 | 153.00 |
5-19 | VLDL Colesterol (mg/dl) | 6 | 12.00 | 13.500 | 15.500 | 20.500 | 30.00 |
20+ | Colesterol (mg/dl) | 38 | 104.00 | 135.750 | 160.000 | 179.750 | 628.00 |
20+ | Edad Actual | 38 | 20.04 | 27.093 | 41.075 | 57.070 | 74.08 |
20+ | Glóbulos Blancos | 38 | 5.00 | 6,825.000 | 7,500.000 | 9,125.000 | 14,600.00 |
20+ | Glucosa (mg/dl) | 38 | 81.00 | 95.250 | 101.000 | 107.500 | 139.00 |
20+ | HDL Colesterol (mg/dl) | 38 | 38.00 | 46.000 | 49.500 | 54.750 | 66.00 |
20+ | Hematocrito (%) | 38 | 32.00 | 42.250 | 46.000 | 50.000 | 56.00 |
20+ | Hemoglobina (g/dl) | 38 | 10.60 | 12.825 | 13.550 | 14.875 | 16.20 |
20+ | LDL Colesterol (mg/dl) | 38 | 25.00 | 61.500 | 80.000 | 102.500 | 556.00 |
20+ | Plaquetas | 38 | 190.00 | 171,250.000 | 187,500.000 | 223,750.000 | 343,000.00 |
20+ | Triglicéridos (mg/dl) | 38 | 57.00 | 91.750 | 110.000 | 148.750 | 332.00 |
20+ | VLDL Colesterol (mg/dl) | 38 | 11.00 | 18.250 | 22.000 | 29.750 | 99.00 |
sjSanguineoE_ft %>%
theme_alafoli()
Maximo | |||||||
Grupo de edades | Variable | n | Min. | Q1. | Mediana | Q3. | Max. |
5-19 | Colesterol (mg/dl) | 6 | 111.00 | 123.000 | 132.500 | 145.750 | 150.00 |
5-19 | Edad Actual | 6 | 14.05 | 17.020 | 17.060 | 17.798 | 19.08 |
5-19 | Glóbulos Blancos | 6 | 9,000.00 | 9,925.000 | 11,200.000 | 15,325.000 | 131,000.00 |
5-19 | Glucosa (mg/dl) | 6 | 90.00 | 91.750 | 96.000 | 104.000 | 108.00 |
5-19 | HDL Colesterol (mg/dl) | 6 | 47.00 | 48.000 | 48.500 | 50.500 | 59.00 |
5-19 | Hematocrito (%) | 6 | 39.00 | 41.250 | 42.500 | 46.000 | 49.00 |
5-19 | Hemoglobina (g/dl) | 6 | 11.20 | 12.550 | 13.500 | 14.075 | 14.20 |
5-19 | LDL Colesterol (mg/dl) | 6 | 49.00 | 57.500 | 62.000 | 69.500 | 85.00 |
5-19 | Plaquetas | 6 | 30,100.00 | 177,500.000 | 201,500.000 | 260,750.000 | 294,000.00 |
5-19 | Triglicéridos (mg/dl) | 6 | 62.00 | 69.750 | 79.000 | 102.500 | 153.00 |
5-19 | VLDL Colesterol (mg/dl) | 6 | 12.00 | 13.500 | 15.500 | 20.500 | 30.00 |
20+ | Colesterol (mg/dl) | 38 | 104.00 | 135.750 | 160.000 | 179.750 | 628.00 |
20+ | Edad Actual | 38 | 20.04 | 27.093 | 41.075 | 57.070 | 74.08 |
20+ | Glóbulos Blancos | 38 | 5.00 | 6,825.000 | 7,500.000 | 9,125.000 | 14,600.00 |
20+ | Glucosa (mg/dl) | 38 | 81.00 | 95.250 | 101.000 | 107.500 | 139.00 |
20+ | HDL Colesterol (mg/dl) | 38 | 38.00 | 46.000 | 49.500 | 54.750 | 66.00 |
20+ | Hematocrito (%) | 38 | 32.00 | 42.250 | 46.000 | 50.000 | 56.00 |
20+ | Hemoglobina (g/dl) | 38 | 10.60 | 12.825 | 13.550 | 14.875 | 16.20 |
20+ | LDL Colesterol (mg/dl) | 38 | 25.00 | 61.500 | 80.000 | 102.500 | 556.00 |
20+ | Plaquetas | 38 | 190.00 | 171,250.000 | 187,500.000 | 223,750.000 | 343,000.00 |
20+ | Triglicéridos (mg/dl) | 38 | 57.00 | 91.750 | 110.000 | 148.750 | 332.00 |
20+ | VLDL Colesterol (mg/dl) | 38 | 11.00 | 18.250 | 22.000 | 29.750 | 99.00 |
sjSanguineoE_ft %>%
theme_apa()
Maximo | |||||||
Grupo de edades | Variable | n | Min. | Q1. | Mediana | Q3. | Max. |
5-19 | Colesterol (mg/dl) | 6.00 | 111.00 | 123.00 | 132.50 | 145.75 | 150.00 |
5-19 | Edad Actual | 6.00 | 14.05 | 17.02 | 17.06 | 17.80 | 19.08 |
5-19 | Glóbulos Blancos | 6.00 | 9,000.00 | 9,925.00 | 11,200.00 | 15,325.00 | 131,000.00 |
5-19 | Glucosa (mg/dl) | 6.00 | 90.00 | 91.75 | 96.00 | 104.00 | 108.00 |
5-19 | HDL Colesterol (mg/dl) | 6.00 | 47.00 | 48.00 | 48.50 | 50.50 | 59.00 |
5-19 | Hematocrito (%) | 6.00 | 39.00 | 41.25 | 42.50 | 46.00 | 49.00 |
5-19 | Hemoglobina (g/dl) | 6.00 | 11.20 | 12.55 | 13.50 | 14.07 | 14.20 |
5-19 | LDL Colesterol (mg/dl) | 6.00 | 49.00 | 57.50 | 62.00 | 69.50 | 85.00 |
5-19 | Plaquetas | 6.00 | 30,100.00 | 177,500.00 | 201,500.00 | 260,750.00 | 294,000.00 |
5-19 | Triglicéridos (mg/dl) | 6.00 | 62.00 | 69.75 | 79.00 | 102.50 | 153.00 |
5-19 | VLDL Colesterol (mg/dl) | 6.00 | 12.00 | 13.50 | 15.50 | 20.50 | 30.00 |
20+ | Colesterol (mg/dl) | 38.00 | 104.00 | 135.75 | 160.00 | 179.75 | 628.00 |
20+ | Edad Actual | 38.00 | 20.04 | 27.09 | 41.08 | 57.07 | 74.08 |
20+ | Glóbulos Blancos | 38.00 | 5.00 | 6,825.00 | 7,500.00 | 9,125.00 | 14,600.00 |
20+ | Glucosa (mg/dl) | 38.00 | 81.00 | 95.25 | 101.00 | 107.50 | 139.00 |
20+ | HDL Colesterol (mg/dl) | 38.00 | 38.00 | 46.00 | 49.50 | 54.75 | 66.00 |
20+ | Hematocrito (%) | 38.00 | 32.00 | 42.25 | 46.00 | 50.00 | 56.00 |
20+ | Hemoglobina (g/dl) | 38.00 | 10.60 | 12.82 | 13.55 | 14.88 | 16.20 |
20+ | LDL Colesterol (mg/dl) | 38.00 | 25.00 | 61.50 | 80.00 | 102.50 | 556.00 |
20+ | Plaquetas | 38.00 | 190.00 | 171,250.00 | 187,500.00 | 223,750.00 | 343,000.00 |
20+ | Triglicéridos (mg/dl) | 38.00 | 57.00 | 91.75 | 110.00 | 148.75 | 332.00 |
20+ | VLDL Colesterol (mg/dl) | 38.00 | 11.00 | 18.25 | 22.00 | 29.75 | 99.00 |
NA
sjSanguineoE_ft %>%
theme_booktabs()
Maximo | |||||||
Grupo de edades | Variable | n | Min. | Q1. | Mediana | Q3. | Max. |
5-19 | Colesterol (mg/dl) | 6 | 111.00 | 123.000 | 132.500 | 145.750 | 150.00 |
5-19 | Edad Actual | 6 | 14.05 | 17.020 | 17.060 | 17.798 | 19.08 |
5-19 | Glóbulos Blancos | 6 | 9,000.00 | 9,925.000 | 11,200.000 | 15,325.000 | 131,000.00 |
5-19 | Glucosa (mg/dl) | 6 | 90.00 | 91.750 | 96.000 | 104.000 | 108.00 |
5-19 | HDL Colesterol (mg/dl) | 6 | 47.00 | 48.000 | 48.500 | 50.500 | 59.00 |
5-19 | Hematocrito (%) | 6 | 39.00 | 41.250 | 42.500 | 46.000 | 49.00 |
5-19 | Hemoglobina (g/dl) | 6 | 11.20 | 12.550 | 13.500 | 14.075 | 14.20 |
5-19 | LDL Colesterol (mg/dl) | 6 | 49.00 | 57.500 | 62.000 | 69.500 | 85.00 |
5-19 | Plaquetas | 6 | 30,100.00 | 177,500.000 | 201,500.000 | 260,750.000 | 294,000.00 |
5-19 | Triglicéridos (mg/dl) | 6 | 62.00 | 69.750 | 79.000 | 102.500 | 153.00 |
5-19 | VLDL Colesterol (mg/dl) | 6 | 12.00 | 13.500 | 15.500 | 20.500 | 30.00 |
20+ | Colesterol (mg/dl) | 38 | 104.00 | 135.750 | 160.000 | 179.750 | 628.00 |
20+ | Edad Actual | 38 | 20.04 | 27.093 | 41.075 | 57.070 | 74.08 |
20+ | Glóbulos Blancos | 38 | 5.00 | 6,825.000 | 7,500.000 | 9,125.000 | 14,600.00 |
20+ | Glucosa (mg/dl) | 38 | 81.00 | 95.250 | 101.000 | 107.500 | 139.00 |
20+ | HDL Colesterol (mg/dl) | 38 | 38.00 | 46.000 | 49.500 | 54.750 | 66.00 |
20+ | Hematocrito (%) | 38 | 32.00 | 42.250 | 46.000 | 50.000 | 56.00 |
20+ | Hemoglobina (g/dl) | 38 | 10.60 | 12.825 | 13.550 | 14.875 | 16.20 |
20+ | LDL Colesterol (mg/dl) | 38 | 25.00 | 61.500 | 80.000 | 102.500 | 556.00 |
20+ | Plaquetas | 38 | 190.00 | 171,250.000 | 187,500.000 | 223,750.000 | 343,000.00 |
20+ | Triglicéridos (mg/dl) | 38 | 57.00 | 91.750 | 110.000 | 148.750 | 332.00 |
20+ | VLDL Colesterol (mg/dl) | 38 | 11.00 | 18.250 | 22.000 | 29.750 | 99.00 |
sjSanguineoE_ft %>%
theme_tron()
Maximo | |||||||
Grupo de edades | Variable | n | Min. | Q1. | Mediana | Q3. | Max. |
5-19 | Colesterol (mg/dl) | 6 | 111.00 | 123.000 | 132.500 | 145.750 | 150.00 |
5-19 | Edad Actual | 6 | 14.05 | 17.020 | 17.060 | 17.798 | 19.08 |
5-19 | Glóbulos Blancos | 6 | 9,000.00 | 9,925.000 | 11,200.000 | 15,325.000 | 131,000.00 |
5-19 | Glucosa (mg/dl) | 6 | 90.00 | 91.750 | 96.000 | 104.000 | 108.00 |
5-19 | HDL Colesterol (mg/dl) | 6 | 47.00 | 48.000 | 48.500 | 50.500 | 59.00 |
5-19 | Hematocrito (%) | 6 | 39.00 | 41.250 | 42.500 | 46.000 | 49.00 |
5-19 | Hemoglobina (g/dl) | 6 | 11.20 | 12.550 | 13.500 | 14.075 | 14.20 |
5-19 | LDL Colesterol (mg/dl) | 6 | 49.00 | 57.500 | 62.000 | 69.500 | 85.00 |
5-19 | Plaquetas | 6 | 30,100.00 | 177,500.000 | 201,500.000 | 260,750.000 | 294,000.00 |
5-19 | Triglicéridos (mg/dl) | 6 | 62.00 | 69.750 | 79.000 | 102.500 | 153.00 |
5-19 | VLDL Colesterol (mg/dl) | 6 | 12.00 | 13.500 | 15.500 | 20.500 | 30.00 |
20+ | Colesterol (mg/dl) | 38 | 104.00 | 135.750 | 160.000 | 179.750 | 628.00 |
20+ | Edad Actual | 38 | 20.04 | 27.093 | 41.075 | 57.070 | 74.08 |
20+ | Glóbulos Blancos | 38 | 5.00 | 6,825.000 | 7,500.000 | 9,125.000 | 14,600.00 |
20+ | Glucosa (mg/dl) | 38 | 81.00 | 95.250 | 101.000 | 107.500 | 139.00 |
20+ | HDL Colesterol (mg/dl) | 38 | 38.00 | 46.000 | 49.500 | 54.750 | 66.00 |
20+ | Hematocrito (%) | 38 | 32.00 | 42.250 | 46.000 | 50.000 | 56.00 |
20+ | Hemoglobina (g/dl) | 38 | 10.60 | 12.825 | 13.550 | 14.875 | 16.20 |
20+ | LDL Colesterol (mg/dl) | 38 | 25.00 | 61.500 | 80.000 | 102.500 | 556.00 |
20+ | Plaquetas | 38 | 190.00 | 171,250.000 | 187,500.000 | 223,750.000 | 343,000.00 |
20+ | Triglicéridos (mg/dl) | 38 | 57.00 | 91.750 | 110.000 | 148.750 | 332.00 |
20+ | VLDL Colesterol (mg/dl) | 38 | 11.00 | 18.250 | 22.000 | 29.750 | 99.00 |
sjSanguineoE_ft %>%
theme_tron_legacy()
Maximo | |||||||
Grupo de edades | Variable | n | Min. | Q1. | Mediana | Q3. | Max. |
5-19 | Colesterol (mg/dl) | 6 | 111.00 | 123.000 | 132.500 | 145.750 | 150.00 |
5-19 | Edad Actual | 6 | 14.05 | 17.020 | 17.060 | 17.798 | 19.08 |
5-19 | Glóbulos Blancos | 6 | 9,000.00 | 9,925.000 | 11,200.000 | 15,325.000 | 131,000.00 |
5-19 | Glucosa (mg/dl) | 6 | 90.00 | 91.750 | 96.000 | 104.000 | 108.00 |
5-19 | HDL Colesterol (mg/dl) | 6 | 47.00 | 48.000 | 48.500 | 50.500 | 59.00 |
5-19 | Hematocrito (%) | 6 | 39.00 | 41.250 | 42.500 | 46.000 | 49.00 |
5-19 | Hemoglobina (g/dl) | 6 | 11.20 | 12.550 | 13.500 | 14.075 | 14.20 |
5-19 | LDL Colesterol (mg/dl) | 6 | 49.00 | 57.500 | 62.000 | 69.500 | 85.00 |
5-19 | Plaquetas | 6 | 30,100.00 | 177,500.000 | 201,500.000 | 260,750.000 | 294,000.00 |
5-19 | Triglicéridos (mg/dl) | 6 | 62.00 | 69.750 | 79.000 | 102.500 | 153.00 |
5-19 | VLDL Colesterol (mg/dl) | 6 | 12.00 | 13.500 | 15.500 | 20.500 | 30.00 |
20+ | Colesterol (mg/dl) | 38 | 104.00 | 135.750 | 160.000 | 179.750 | 628.00 |
20+ | Edad Actual | 38 | 20.04 | 27.093 | 41.075 | 57.070 | 74.08 |
20+ | Glóbulos Blancos | 38 | 5.00 | 6,825.000 | 7,500.000 | 9,125.000 | 14,600.00 |
20+ | Glucosa (mg/dl) | 38 | 81.00 | 95.250 | 101.000 | 107.500 | 139.00 |
20+ | HDL Colesterol (mg/dl) | 38 | 38.00 | 46.000 | 49.500 | 54.750 | 66.00 |
20+ | Hematocrito (%) | 38 | 32.00 | 42.250 | 46.000 | 50.000 | 56.00 |
20+ | Hemoglobina (g/dl) | 38 | 10.60 | 12.825 | 13.550 | 14.875 | 16.20 |
20+ | LDL Colesterol (mg/dl) | 38 | 25.00 | 61.500 | 80.000 | 102.500 | 556.00 |
20+ | Plaquetas | 38 | 190.00 | 171,250.000 | 187,500.000 | 223,750.000 | 343,000.00 |
20+ | Triglicéridos (mg/dl) | 38 | 57.00 | 91.750 | 110.000 | 148.750 | 332.00 |
20+ | VLDL Colesterol (mg/dl) | 38 | 11.00 | 18.250 | 22.000 | 29.750 | 99.00 |
sjSanguineoE_ft %>%
theme_vader()
Maximo | |||||||
Grupo de edades | Variable | n | Min. | Q1. | Mediana | Q3. | Max. |
5-19 | Colesterol (mg/dl) | 6 | 111.00 | 123.000 | 132.500 | 145.750 | 150.00 |
5-19 | Edad Actual | 6 | 14.05 | 17.020 | 17.060 | 17.798 | 19.08 |
5-19 | Glóbulos Blancos | 6 | 9,000.00 | 9,925.000 | 11,200.000 | 15,325.000 | 131,000.00 |
5-19 | Glucosa (mg/dl) | 6 | 90.00 | 91.750 | 96.000 | 104.000 | 108.00 |
5-19 | HDL Colesterol (mg/dl) | 6 | 47.00 | 48.000 | 48.500 | 50.500 | 59.00 |
5-19 | Hematocrito (%) | 6 | 39.00 | 41.250 | 42.500 | 46.000 | 49.00 |
5-19 | Hemoglobina (g/dl) | 6 | 11.20 | 12.550 | 13.500 | 14.075 | 14.20 |
5-19 | LDL Colesterol (mg/dl) | 6 | 49.00 | 57.500 | 62.000 | 69.500 | 85.00 |
5-19 | Plaquetas | 6 | 30,100.00 | 177,500.000 | 201,500.000 | 260,750.000 | 294,000.00 |
5-19 | Triglicéridos (mg/dl) | 6 | 62.00 | 69.750 | 79.000 | 102.500 | 153.00 |
5-19 | VLDL Colesterol (mg/dl) | 6 | 12.00 | 13.500 | 15.500 | 20.500 | 30.00 |
20+ | Colesterol (mg/dl) | 38 | 104.00 | 135.750 | 160.000 | 179.750 | 628.00 |
20+ | Edad Actual | 38 | 20.04 | 27.093 | 41.075 | 57.070 | 74.08 |
20+ | Glóbulos Blancos | 38 | 5.00 | 6,825.000 | 7,500.000 | 9,125.000 | 14,600.00 |
20+ | Glucosa (mg/dl) | 38 | 81.00 | 95.250 | 101.000 | 107.500 | 139.00 |
20+ | HDL Colesterol (mg/dl) | 38 | 38.00 | 46.000 | 49.500 | 54.750 | 66.00 |
20+ | Hematocrito (%) | 38 | 32.00 | 42.250 | 46.000 | 50.000 | 56.00 |
20+ | Hemoglobina (g/dl) | 38 | 10.60 | 12.825 | 13.550 | 14.875 | 16.20 |
20+ | LDL Colesterol (mg/dl) | 38 | 25.00 | 61.500 | 80.000 | 102.500 | 556.00 |
20+ | Plaquetas | 38 | 190.00 | 171,250.000 | 187,500.000 | 223,750.000 | 343,000.00 |
20+ | Triglicéridos (mg/dl) | 38 | 57.00 | 91.750 | 110.000 | 148.750 | 332.00 |
20+ | VLDL Colesterol (mg/dl) | 38 | 11.00 | 18.250 | 22.000 | 29.750 | 99.00 |
sjSanguineoE_ft %>%
theme_zebra()
Maximo | |||||||
Grupo de edades | Variable | n | Min. | Q1. | Mediana | Q3. | Max. |
5-19 | Colesterol (mg/dl) | 6 | 111.00 | 123.000 | 132.500 | 145.750 | 150.00 |
5-19 | Edad Actual | 6 | 14.05 | 17.020 | 17.060 | 17.798 | 19.08 |
5-19 | Glóbulos Blancos | 6 | 9,000.00 | 9,925.000 | 11,200.000 | 15,325.000 | 131,000.00 |
5-19 | Glucosa (mg/dl) | 6 | 90.00 | 91.750 | 96.000 | 104.000 | 108.00 |
5-19 | HDL Colesterol (mg/dl) | 6 | 47.00 | 48.000 | 48.500 | 50.500 | 59.00 |
5-19 | Hematocrito (%) | 6 | 39.00 | 41.250 | 42.500 | 46.000 | 49.00 |
5-19 | Hemoglobina (g/dl) | 6 | 11.20 | 12.550 | 13.500 | 14.075 | 14.20 |
5-19 | LDL Colesterol (mg/dl) | 6 | 49.00 | 57.500 | 62.000 | 69.500 | 85.00 |
5-19 | Plaquetas | 6 | 30,100.00 | 177,500.000 | 201,500.000 | 260,750.000 | 294,000.00 |
5-19 | Triglicéridos (mg/dl) | 6 | 62.00 | 69.750 | 79.000 | 102.500 | 153.00 |
5-19 | VLDL Colesterol (mg/dl) | 6 | 12.00 | 13.500 | 15.500 | 20.500 | 30.00 |
20+ | Colesterol (mg/dl) | 38 | 104.00 | 135.750 | 160.000 | 179.750 | 628.00 |
20+ | Edad Actual | 38 | 20.04 | 27.093 | 41.075 | 57.070 | 74.08 |
20+ | Glóbulos Blancos | 38 | 5.00 | 6,825.000 | 7,500.000 | 9,125.000 | 14,600.00 |
20+ | Glucosa (mg/dl) | 38 | 81.00 | 95.250 | 101.000 | 107.500 | 139.00 |
20+ | HDL Colesterol (mg/dl) | 38 | 38.00 | 46.000 | 49.500 | 54.750 | 66.00 |
20+ | Hematocrito (%) | 38 | 32.00 | 42.250 | 46.000 | 50.000 | 56.00 |
20+ | Hemoglobina (g/dl) | 38 | 10.60 | 12.825 | 13.550 | 14.875 | 16.20 |
20+ | LDL Colesterol (mg/dl) | 38 | 25.00 | 61.500 | 80.000 | 102.500 | 556.00 |
20+ | Plaquetas | 38 | 190.00 | 171,250.000 | 187,500.000 | 223,750.000 | 343,000.00 |
20+ | Triglicéridos (mg/dl) | 38 | 57.00 | 91.750 | 110.000 | 148.750 | 332.00 |
20+ | VLDL Colesterol (mg/dl) | 38 | 11.00 | 18.250 | 22.000 | 29.750 | 99.00 |
Crear una tabla desde cero
# trabajo com mtcars
head(mtcars)
Ejemplo adicional
head(diamonds)
Toma el precio medio de los diamantes, despliega las categorias de la variable “cut” y muestra la densidad de cada uno de los lados del diamante
# tranformo el dataset diamons en una matriz de datos
z <- as.data.table(diamonds)
# trabajo con los valores medios de una de las columnas
z <- z[, list(
price = mean(price, na.rm = TRUE),
list_col = list(.SD$x) # extraigo todos los valores de las numericas
), by = "cut"] # agrupo by cut..
ft <- flextable(data = z) %>%
compose(j = "list_col",
value = as_paragraph(
plot_chunk(value = list_col,
type = "dens",
col = "pink",
width = 1.5,
height = .4,
free_scale = TRUE) )) %>%
colformat_double(big.mark = " ",
suffix = " $") %>%
set_header_labels(box = "composite content",
density = "density") %>%
autofit()
ft
cut | price | list_col |
Ideal | 3 457.5 $ | |
Premium | 4 584.3 $ | |
Good | 3 928.9 $ | |
Very Good | 3 981.8 $ | |
Fair | 4 358.8 $ |
NA
Bajar el número de decimales y crear un solo grupo por cada tramo de edades
sjSanguineoE_ft <- sjSanguineoE_ft |> # transformo en tabla flex
theme_booktabs(bold_header = TRUE)|> # negritas en el encabezamiento
autofit() |>
merge_v(j = 1) |>
merge_v(j = 2) |>
valign(j = 1, valign = "top")|>
valign(j = 2, valign = "top")|>
align(align = "center", part = "all", j = 3:8)
No hay comentarios.:
Publicar un comentario