left: Return the leftmost or rightmost columns of a matrix or...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/left.R

Description

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

Usage

1
2
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

first, last, head, tail

Examples

1
2
3
4
5
6
7
8
 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)

Example output

gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.

gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.

Attaching package: 'gdata'

The following object is masked from 'package:stats':

    nobs

The following object is masked from 'package:utils':

    object.size

The following object is masked from 'package:base':

    startsWith

      Col_1 Col_2 Col_3 Col_4 Col_5 Col_6
 [1,]     1    11    21    31    41    51
 [2,]     2    12    22    32    42    52
 [3,]     3    13    23    33    43    53
 [4,]     4    14    24    34    44    54
 [5,]     5    15    25    35    45    55
 [6,]     6    16    26    36    46    56
 [7,]     7    17    27    37    47    57
 [8,]     8    18    28    38    48    58
 [9,]     9    19    29    39    49    59
[10,]    10    20    30    40    50    60
      Col_1 Col_2 Col_3 Col_4 Col_5 Col_6
 [1,]     1    11    21    31    41    51
 [2,]     2    12    22    32    42    52
 [3,]     3    13    23    33    43    53
 [4,]     4    14    24    34    44    54
 [5,]     5    15    25    35    45    55
 [6,]     6    16    26    36    46    56
 [7,]     7    17    27    37    47    57
 [8,]     8    18    28    38    48    58
 [9,]     9    19    29    39    49    59
[10,]    10    20    30    40    50    60
   Col_1 Col_2 Col_3 Col_4 Col_5 Col_6
1      1    11    21    31    41    51
2      2    12    22    32    42    52
3      3    13    23    33    43    53
4      4    14    24    34    44    54
5      5    15    25    35    45    55
6      6    16    26    36    46    56
7      7    17    27    37    47    57
8      8    18    28    38    48    58
9      9    19    29    39    49    59
10    10    20    30    40    50    60
   Col_1 Col_2 Col_3 Col_4 Col_5 Col_6
1      1    11    21    31    41    51
2      2    12    22    32    42    52
3      3    13    23    33    43    53
4      4    14    24    34    44    54
5      5    15    25    35    45    55
6      6    16    26    36    46    56
7      7    17    27    37    47    57
8      8    18    28    38    48    58
9      9    19    29    39    49    59
10    10    20    30    40    50    60

gdata documentation built on May 2, 2019, 5:49 p.m.