des                 package:epicalc                 R Documentation

_D_e_s_r_i_p_t_i_o_n _o_f _a _d_a_t_a _f_r_a_m_e _o_r _a _v_a_r_i_a_b_l_e

_D_e_s_c_r_i_p_t_i_o_n:

     Description of a data frame or a variable or wildcard for variable
     names

_U_s_a_g_e:

     des(x=.data, select, exclude)

_A_r_g_u_m_e_n_t_s:

       x: an object such as a vector (variable), a matrix, a table, a
          list or a data frame

  select: expression, indicating columns to select from '.data.'

 exclude: expression, indicating columns to exclude

_D_e_t_a_i_l_s:

     The default value of x (ie if no argument is supplied) is '.data'.
     If 'x' is a data frame, its variable names will be listed with
     class and the description of each variable. 

     If 'x' is a variable, the environment and attached data frame
     containing 'x' will be described.

     For a data frame containing too many variables, 'select' and
     'exclude' can be specified to display fewer variable descriptions
     at a time. Unlike 'keepVar', these two arguments do not have any
     permanent effect on the data frame.

_A_u_t_h_o_r(_s):

     Virasakdi Chongsuvivatwong <cvirasak@medicine.psu.ac.th>

_S_e_e _A_l_s_o:

     'use', 'summ', 'label.var', 'subset' and 'keepData'

_E_x_a_m_p_l_e_s:

     data(Oswego)
     use(Oswego)
     # In the tutorial, when "oswego.rec" which is an EpiInfo file is available,
     # instead of typing the above two lines, one can directly type:
     # use("oswego.rec")

     des() # This is one of the most useful Epicalc functions!

     #### Detection of variables of the same name in different data frames.
     # Note that 'age' is a variable in '.data' due to the function 'use'.
     des(Oswego) # Same results. Note that 'age' is also in 'Oswego'.
     des(infert) # The third 'age' is in another data frame,
                     # from the datasets package in R, 'infert'.
     attach(infert)
     search() # Show all data frames that are in the search path
     des(sex) # 'sex' is found only in '.data'
     des(induced)
     age <- "abc" # Just a silly example for a variable
     des(age)     # Shows all occurrences of 'age', wherever it is
     rm(age)
     detachAllData()

     #### Wildcard for variables
     use(Oswego)
     des("c*")     # Show all variables starting with 'c'
     des("?????")  # Show all variables with 5 characters in the name

     agegr <- cut(age, breaks=c(0,20,40,60,80))
     label.var(agegr, "age group")
     # Note that the above line incoperates 'agegr' into '.data
     # making it eligible to be included in the group under the following wildcard
     des("age*") 

     #### Subset of variables in .data
     des(select = 1:5) # First five variables
     des(select = age:onsetdate) # Same results

     des(select = c(1,2,5,20))
     des(select = c(age, sex, onsetdate, fruitsalad))

     des(select = sex:chocolate)

     ## The following six lines give the same results
     des(select = -(sex:chocolate))
     des(select = -sex:-chocolate) 
     des(select = -(2:19))
     des(select = -19:-2)
     des(exclude = sex:chocolate)
     des(exclude = 2:19)

     #### Wildcard: same effects with or without 'select'
     des(select = "c*")
     des("c*")

     ## Exclusion using wildcard, however, needs an 'exclude' argument.
     des(exclude = "c*")

