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

left

Return the leftmost or rightmost columns of a matrix or dataframe


Description

Return the leftmost or rightmost or columns of a matrix or dataframe

Usage

right(x, n = 6)
left(x, n=6)

Arguments

x

Matrix or dataframe

n

Number of columns to return

Value

An object consisting of the leftmost or rightmost n columns of x.

Author(s)

Gregory R. Warnes greg@warnes.net

See Also

Examples

m <- matrix( 1:100, ncol=10 )
 colnames(m) <- paste("Col",1:10, sep="_")
 left(m)
 right(m)

 d <- as.data.frame(m)
 left(d)
 right(d)

gdata

Various R Programming Tools for Data Manipulation

v2.18.0
GPL-2
Authors
Gregory R. Warnes, Ben Bolker, Gregor Gorjanc, Gabor Grothendieck, Ales Korosec, Thomas Lumley, Don MacQueen, Arni Magnusson, Jim Rogers, and others
Initial release
2017-06-05

We don't support your browser anymore

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