Learn R Programming

dummies (version 1.03)

get.dummy: Get the dummy variable columns from a data frame.

Description

Given a data.frame and an optional variables name, return only the columns whtat are dummy variables

Usage

get.dummy(data, name = NULL)
get.dummies(data, name = NULL)

Arguments

data
A data.frame with an dummies attributes
name
Optional. The name of a variable.

Value

  • The subset of data that are dummy columns.

Details

This uses which.dummy to identify the dummy columns.

See Also

which.dummy, dummy.data.frame

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(data,name=NULL) {
    
  if( ! is.null(name) ) {
    dat <- data[ , which.dummy(data, name) ]  
  } else {
    dat <- data[ , which.dummy(data) ] 
  }

  return(dat)
  }

Run the code above in your browser using DataLab