pyramid               package:epicalc               R Documentation

_P_o_p_u_l_a_t_i_o_n _p_y_r_a_m_i_d

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

     Create a population pyramid from age and sex

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

     pyramid (age, sex, binwidth=5, inputTable=NULL, printTable=FALSE, 
       percent=c("none","each","total"), decimal=3, ...)

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

     age: a numeric variable for age

     sex: a variable of two levels for sexes, can be numeric but
          preferrably factor with labelled levels or characters

binwidth: bin width of age for each bar

inputTable: a table to read in with two columns of sexes and rows of
          age groups

printTable: whether the output table would be displayed on the console

 percent: whether the lengths of the bars should be calculated from
          freqencies (default), percentages of each sex or total
          percentages

 decimal: number of decimals displayed in the percent output table

     ...: graph options for the bars e.g. col

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

     'pyramid' draws a horizontal bar graph of age by sex. 

     Parameters of graph (par) options can be applied to 'font.lab' and
     those of the bars e.g. 'col' but not of others.

     Other lower level graph commands should be only for adding a
     'title'.

_V_a_l_u_e:

     When the variables age and sex are input arguments, the return
     objects include age group variable and the output table. The
     argument 'decimal' controls only decimals of the output displayed
     on the console but not the returned table.

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

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

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

     'barplot', 'levels', 'table'

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

     data(Oswego)
     .data <- Oswego
     attach(.data)

     # The above lines generate a hypothetical data frame. 
     # In reality, one just exploits 'use("Oswego.rec"), if the file is available.

     pyramid(age, sex)
     pyramid(age, sex, printTable=TRUE)
     pyramid(age, sex, col="red")
     pyramid(age, sex, col=1:16) # Too colorful!
     output <- pyramid(age, sex, binwidth = 10, percent="each", decimal=2)
     title(main="Frequency of age group (years) by sex") 
     output
     tabpct(output$ageGroup, chocolate)

     pyramid(inputTable=VADeaths[,1:2], font.lab=4)
     title("Death rates per 100 in rural Virginia in 1940")
      

