7.00.02.01 - Example 1: ta.colApply() - Aster R

Teradata Aster® R User GuideUpdate 3

prodname
Aster R
vrm_release
7.00.02.01
created_date
December 2017
category
Programming Reference
User Guide
featnum
B700-1033-700K
This example uses the dataset "Pima.tr" found in the R package "MASS".
  1. Convert the dataset to an Aster virtual data frame "tadf_Pima_tr", and list the first six rows of the data frame.
    tadf_Pima_tr<-as.ta.data.frame(Pima.tr)
    
    ta.head(tadf_Pima_tr)
      npreg  glu  bp skin   bmi    ped age type
    1     5   86  68   28  30.2  0.364  24   No
    2     7  195  70   33  25.1  0.163  55  Yes
    3     5   77  82   41  35.8  0.156  35   No
    4     0  165  76   43  47.9  0.259  26   No
    5     0  107  60   25  26.4  0.133  23   No
    6     5   97  76   27  35.6  0.378  52  Yes
  2. Use the Aster R runner function ta.colApply() to calculate the mean of each numeric column in the dataset.
    ta.colApply(tadf_Pima_tr[1:7], mean)
    
        npreg        glu        bp      skin       bmi      ped       age
     3.570000 123.970000 71.260000 29.215000 32.310000 0.460765 32.110000