Learn R Programming

modellingTools (version 0.1.0)

column_vector: Get the contents of a single column of a tbl

Description

Function to return a vector with the contents of one column of a tbl_df The type of the column will be preserved if numeric or factor; all else will be conveted to a vector of character strings

Usage

column_vector(d, i)

Arguments

d
a tbl
i
a character string containing the name of the column to be returned OR a single number representing the position of the column to be returned

Value

A vector containing the values from the specified column. The type will be numeric, factor, or character, depending on the type of the original column

Examples

Run this code
x <- dplyr::tbl_df(iris)
column_vector(x,2)
column_vector(x,"Species")

Run the code above in your browser using DataLab