mtcars2 {crosstable} | R Documentation |
Modified mtcars
dataset
Description
Modified mtcars
dataset so:
every column is labelled (using
label
attribute)rownames are a character column named
model
-
gear
andcyl
columns are considered as numerical factors -
vs
andam
columns are considered as character vector
See mtcars
for more informations on the original "Motor Trend Car Road Tests" dataset.
Usage
mtcars2
Format
A data frame with 32 observations on 11 variables with labels.
Source
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" )
Examples
library(crosstable)
ct=crosstable(mtcars2, by=vs)
ct
as_flextable(ct)
[Package crosstable version 0.7.0 Index]