Previous Page Next Page Contents

stats::col -- select and re-arrange columns of a sample

Introduction

stats::col(s, ..) creates a new sample from selected columns of the sample s.

Call(s)

stats::col(s, c1 <, c2, ..>)
stats::col(s, c1..c2 <, c3..c4, ..>)

Parameters

s - a sample of domain type stats::sample.
c1, c2, .. - positive integers representing column indices of the sample s.

Returns

a sample of domain type stats::sample.

Related Functions

stats::concatCol, stats::concatRow, stats::row

Details

Example 1

The following sample contains columns for ``gender'', ``age'', ``height'', the ``number of yellow socks'' and ``eye color'' of a person:

>> stats::sample([["m", 26, 180, 3, "blue"], 
                  ["f", 22, 160, 0, "brown"], 
                  ["f", 48, 155, 2, "green"], 
                  ["m", 30, 172, 1, "brown"]])
   
                        "m"  26  180  3  "blue"
                        "f"  22  160  0  "brown"
                        "f"  48  155  2  "green"
                        "m"  30  172  1  "brown"

Since nobody is really interested in the yellow socks, we create a new sample without that column:

>> stats::col(%, 1..3, 5)
                          "m"  26  180  "blue"
                          "f"  22  160  "brown"
                          "f"  48  155  "green"
                          "m"  30  172  "brown"

We can use stats::col to re-arrange the sample. As an illustrating example, we duplicate the first column:

>> stats::col(%, 1, 3, 2, 1, 4)
   
                       "m"  180  26  "m"  "blue"
                       "f"  160  22  "f"  "brown"
                       "f"  155  48  "f"  "green"
                       "m"  172  30  "m"  "brown"
      

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000