Generate a heat map of column types from a data.frame
.
table_heat(
x,
flip = FALSE,
palette = "Set3",
print = interactive(),
sep = "\n"
)
A data.frame
.
logical. If TRUE
the data.frame
is
flipped so that the columns are on the y axis and observations on the x axis.
This is useful when there are many columns or the column names are longer.
A palette to chose from. See
scale_fill_brewer
for more. These choices should
exceed the number of unique column types. Use NULL
to use
ggplot2's default color scheme.
logical. If TRUE
the pot is printed. Option for use in
document construction such as knitr or rmarkdown.
A separator to use between column types. Column types are
determined via sapply(x, class)
. When multiple types are present
these are collapsed. By default the \n
is used.
Returns a ggplot2 object.
By default coumn names retain their order. Column types are ordered
alphabetically in the legend, with NA
appearing last.
# NOT RUN {
table_heat(mtcars) #boring
table_heat(CO2)
table_heat(iris)
table_heat(state_populations)
dat <- r_data_frame(100,
lorem_ipsum,
birth,
animal,
age,
grade, grade,
death,
dummy,
grade_letter
)
table_heat(dat)
table_heat(dat, flip=TRUE)
table_heat(r_data_theme(), flip=TRUE)
## NA values
table_heat(r_na(dat, NULL))
## Colors
table_heat(r_na(dat, NULL), palette = NULL)
table_heat(r_na(dat, NULL), palette = "Set1")
table_heat(r_na(dat, NULL), palette = "Set2")
table_heat(r_na(dat, NULL), palette = "Set1")
table_heat(r_na(dat, NULL), palette = "Dark2")
table_heat(r_na(dat, NULL), palette = "Spectral")
table_heat(r_na(dat, NULL), palette = "Reds")
# }
Run the code above in your browser using DataLab