mtcars2 | R Documentation |
mtcars
datasetModified mtcars
dataset so:
every column is labelled (using label
attribute)
rownames are a character column named model
gear
and cyl
columns are considered as numerical factors
vs
and am
columns are considered as character vector
See mtcars
for more informations on the original "Motor Trend Car Road Tests" dataset.
mtcars2
A data frame with 32 observations on 11 variables with labels.
library(dplyr) mtcars2 = mtcars %>% mutate( model=rownames(mtcars), vs=ifelse(vs==0, "vshaped", "straight"), am=ifelse(am==0, "auto", "manual"), across(c("cyl", "gear"), factor), .before=1 ) %>% expss::apply_labels( #I also could have used [import_labels] or even `labelled::set_variable_labels()` mpg="Miles/(US) gallon", cyl="Number of cylinders", disp="Displacement (cu.in.)", hp="Gross horsepower", drat="Rear axle ratio", wt="Weight (1000 lbs)", qsec="1/4 mile time", vs="Engine", am="Transmission", gear="Number of forward gears", carb="Number of carburetors" )
library(crosstable)
ct=crosstable(mtcars2, by=vs)
ct
as_flextable(ct)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.