as.etable: Convert data.frame/matrix to object of class 'etable'

Description Usage Arguments Value Examples

View source: R/as.etable.R

Description

If x is data.frame then as.etable just adds etable to class attribute of x. If x is matrix then it will be converted to data.frame.

Usage

1
2
3
as.etable(x, rownames_as_row_labels = NULL)

is.etable(x)

Arguments

x

data.frame/matrix

rownames_as_row_labels

logical. If it is TRUE than rownames of x will be added to result as first column with name row_labels. By default row names will be added if they are not NULL and are not sequential numerics.

Value

object of class etable

Examples

1
2
3
4
5
6
7
data(mtcars)
etable_mtcars = as.etable(mtcars)
is.etable(etable_mtcars) #TRUE

etable_mtcars #another 'print' method is used

cor(mtcars) %>% as.etable()

Example output

[1] TRUE
                                                                            
 |                     |  mpg | cyl |  disp |  hp | drat |  wt | qsec | vs |
 | ------------------- | ---- | --- | ----- | --- | ---- | --- | ---- | -- |
 |           Mazda RX4 | 21.0 |   6 | 160.0 | 110 |  3.9 | 2.6 | 16.5 |  0 |
 |       Mazda RX4 Wag | 21.0 |   6 | 160.0 | 110 |  3.9 | 2.9 | 17.0 |  0 |
 |          Datsun 710 | 22.8 |   4 | 108.0 |  93 |  3.8 | 2.3 | 18.6 |  1 |
 |      Hornet 4 Drive | 21.4 |   6 | 258.0 | 110 |  3.1 | 3.2 | 19.4 |  1 |
 |   Hornet Sportabout | 18.7 |   8 | 360.0 | 175 |  3.1 | 3.4 | 17.0 |  0 |
 |             Valiant | 18.1 |   6 | 225.0 | 105 |  2.8 | 3.5 | 20.2 |  1 |
 |          Duster 360 | 14.3 |   8 | 360.0 | 245 |  3.2 | 3.6 | 15.8 |  0 |
 |           Merc 240D | 24.4 |   4 | 146.7 |  62 |  3.7 | 3.2 | 20.0 |  1 |
 |            Merc 230 | 22.8 |   4 | 140.8 |  95 |  3.9 | 3.1 | 22.9 |  1 |
 |            Merc 280 | 19.2 |   6 | 167.6 | 123 |  3.9 | 3.4 | 18.3 |  1 |
 |           Merc 280C | 17.8 |   6 | 167.6 | 123 |  3.9 | 3.4 | 18.9 |  1 |
 |          Merc 450SE | 16.4 |   8 | 275.8 | 180 |  3.1 | 4.1 | 17.4 |  0 |
 |          Merc 450SL | 17.3 |   8 | 275.8 | 180 |  3.1 | 3.7 | 17.6 |  0 |
 |         Merc 450SLC | 15.2 |   8 | 275.8 | 180 |  3.1 | 3.8 | 18.0 |  0 |
 |  Cadillac Fleetwood | 10.4 |   8 | 472.0 | 205 |  2.9 | 5.2 | 18.0 |  0 |
 | Lincoln Continental | 10.4 |   8 | 460.0 | 215 |  3.0 | 5.4 | 17.8 |  0 |
 |   Chrysler Imperial | 14.7 |   8 | 440.0 | 230 |  3.2 | 5.3 | 17.4 |  0 |
 |            Fiat 128 | 32.4 |   4 |  78.7 |  66 |  4.1 | 2.2 | 19.5 |  1 |
 |         Honda Civic | 30.4 |   4 |  75.7 |  52 |  4.9 | 1.6 | 18.5 |  1 |
 |      Toyota Corolla | 33.9 |   4 |  71.1 |  65 |  4.2 | 1.8 | 19.9 |  1 |
 |       Toyota Corona | 21.5 |   4 | 120.1 |  97 |  3.7 | 2.5 | 20.0 |  1 |
 |    Dodge Challenger | 15.5 |   8 | 318.0 | 150 |  2.8 | 3.5 | 16.9 |  0 |
 |         AMC Javelin | 15.2 |   8 | 304.0 | 150 |  3.1 | 3.4 | 17.3 |  0 |
 |          Camaro Z28 | 13.3 |   8 | 350.0 | 245 |  3.7 | 3.8 | 15.4 |  0 |
 |    Pontiac Firebird | 19.2 |   8 | 400.0 | 175 |  3.1 | 3.8 | 17.1 |  0 |
 |           Fiat X1-9 | 27.3 |   4 |  79.0 |  66 |  4.1 | 1.9 | 18.9 |  1 |
 |       Porsche 914-2 | 26.0 |   4 | 120.3 |  91 |  4.4 | 2.1 | 16.7 |  0 |
 |        Lotus Europa | 30.4 |   4 |  95.1 | 113 |  3.8 | 1.5 | 16.9 |  1 |
 |      Ford Pantera L | 15.8 |   8 | 351.0 | 264 |  4.2 | 3.2 | 14.5 |  0 |
 |        Ferrari Dino | 19.7 |   6 | 145.0 | 175 |  3.6 | 2.8 | 15.5 |  0 |
 |       Maserati Bora | 15.0 |   8 | 301.0 | 335 |  3.5 | 3.6 | 14.6 |  0 |
 |          Volvo 142E | 21.4 |   4 | 121.0 | 109 |  4.1 | 2.8 | 18.6 |  1 |
                   
 am | gear | carb |
 -- | ---- | ---- |
  1 |    4 |    4 |
  1 |    4 |    4 |
  1 |    4 |    1 |
  0 |    3 |    1 |
  0 |    3 |    2 |
  0 |    3 |    1 |
  0 |    3 |    4 |
  0 |    4 |    2 |
  0 |    4 |    2 |
  0 |    4 |    4 |
  0 |    4 |    4 |
  0 |    3 |    3 |
  0 |    3 |    3 |
  0 |    3 |    3 |
  0 |    3 |    4 |
  0 |    3 |    4 |
  0 |    3 |    4 |
  1 |    4 |    1 |
  1 |    4 |    2 |
  1 |    4 |    1 |
  0 |    3 |    1 |
  0 |    3 |    2 |
  0 |    3 |    2 |
  0 |    3 |    4 |
  0 |    3 |    2 |
  1 |    4 |    1 |
  1 |    5 |    2 |
  1 |    5 |    2 |
  1 |    5 |    4 |
  1 |    5 |    6 |
  1 |    5 |    8 |
  1 |    4 |    2 |
                                                                               
 |      |  mpg |  cyl | disp |   hp | drat |   wt | qsec |   vs |   am | gear |
 | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
 |  mpg |  1.0 | -0.9 | -0.8 | -0.8 |  0.7 | -0.9 |  0.4 |  0.7 |  0.6 |  0.5 |
 |  cyl | -0.9 |  1.0 |  0.9 |  0.8 | -0.7 |  0.8 | -0.6 | -0.8 | -0.5 | -0.5 |
 | disp | -0.8 |  0.9 |  1.0 |  0.8 | -0.7 |  0.9 | -0.4 | -0.7 | -0.6 | -0.6 |
 |   hp | -0.8 |  0.8 |  0.8 |  1.0 | -0.4 |  0.7 | -0.7 | -0.7 | -0.2 | -0.1 |
 | drat |  0.7 | -0.7 | -0.7 | -0.4 |  1.0 | -0.7 |  0.1 |  0.4 |  0.7 |  0.7 |
 |   wt | -0.9 |  0.8 |  0.9 |  0.7 | -0.7 |  1.0 | -0.2 | -0.6 | -0.7 | -0.6 |
 | qsec |  0.4 | -0.6 | -0.4 | -0.7 |  0.1 | -0.2 |  1.0 |  0.7 | -0.2 | -0.2 |
 |   vs |  0.7 | -0.8 | -0.7 | -0.7 |  0.4 | -0.6 |  0.7 |  1.0 |  0.2 |  0.2 |
 |   am |  0.6 | -0.5 | -0.6 | -0.2 |  0.7 | -0.7 | -0.2 |  0.2 |  1.0 |  0.8 |
 | gear |  0.5 | -0.5 | -0.6 | -0.1 |  0.7 | -0.6 | -0.2 |  0.2 |  0.8 |  1.0 |
 | carb | -0.6 |  0.5 |  0.4 |  0.7 | -0.1 |  0.4 | -0.7 | -0.6 |  0.1 |  0.3 |
       
 carb |
 ---- |
 -0.6 |
  0.5 |
  0.4 |
  0.7 |
 -0.1 |
  0.4 |
 -0.7 |
 -0.6 |
  0.1 |
  0.3 |
  1.0 |

expss documentation built on Jan. 8, 2021, 5:38 p.m.