Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

var_type

Determine variable type


Description

This function returns the type of a variable as character. It is similar to type_sum, however, the return value is not truncated, and var_type() works on data frames and within pipe-chains.

Usage

var_type(x, ..., abbr = FALSE)

Arguments

x

A vector or data frame.

...

Optional, unquoted names of variables that should be selected for further processing. Required, if x is a data frame (and no vector) and only selected variables from x should be processed. You may also use functions like : or tidyselect's select-helpers. See 'Examples' or package-vignette.

abbr

Logical, if TRUE, returns a shortened, abbreviated value for the variable type (as returned by pillar::type_sum()). If FALSE (default), a longer "description" is returned.

Value

The variable type of x, as character.

Examples

data(efc)

var_type(1)
var_type(1L)
var_type("a")

var_type(efc$e42dep)
var_type(to_factor(efc$e42dep))

library(dplyr)
var_type(efc, contains("cop"))

sjmisc

Data and Variable Transformation Functions

v2.8.6
GPL-3
Authors
Daniel Lüdecke [aut, cre] (<https://orcid.org/0000-0002-8895-3206>), Iago Giné-Vázquez [ctb], Alexander Bartel [ctb] (<https://orcid.org/0000-0002-1280-6138>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.