Cumulative Proportion Table

Cumulative frequencies or proportions can be a clearer way to present categorical variables. This allow us to see how many songs in total, or what proportion of all songs, were released before a certain year.

To do this, we use the cumsum() function on the tables. First the frequency table:

table.year <- table(songs$YEAR, 
                    exclude = NULL)
cumsum(table.year)
1916 1922 1928 1929 1931 1932 1935 1936 1938 1939 1940 1941 1944 1946 1949 1950 
   1    2    8   10   12   14   15   16   18   21   22   24   26   28   29   31 
1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 
  34   35   36   40   43   52   55   61   71   76   90   97  114  141  174  211 
1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 
 244  283  314  337  367  394  418  445  468  486  513  538  572  597  616  634 
1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 
 659  681  699  716  734  749  768  778  788  802  813  831  843  850  858  865 
1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 <NA> 
 876  888  895  907  921  930  945  959  975  994 1000 

We can use the same on a proportion table:

cumsum(prop.table(table.year))
 1916  1922  1928  1929  1931  1932  1935  1936  1938  1939  1940  1941  1944 
0.001 0.002 0.008 0.010 0.012 0.014 0.015 0.016 0.018 0.021 0.022 0.024 0.026 
 1946  1949  1950  1951  1952  1953  1954  1955  1956  1957  1958  1959  1960 
0.028 0.029 0.031 0.034 0.035 0.036 0.040 0.043 0.052 0.055 0.061 0.071 0.076 
 1961  1962  1963  1964  1965  1966  1967  1968  1969  1970  1971  1972  1973 
0.090 0.097 0.114 0.141 0.174 0.211 0.244 0.283 0.314 0.337 0.367 0.394 0.418 
 1974  1975  1976  1977  1978  1979  1980  1981  1982  1983  1984  1985  1986 
0.445 0.468 0.486 0.513 0.538 0.572 0.597 0.616 0.634 0.659 0.681 0.699 0.716 
 1987  1988  1989  1990  1991  1992  1993  1994  1995  1996  1997  1998  1999 
0.734 0.749 0.768 0.778 0.788 0.802 0.813 0.831 0.843 0.850 0.858 0.865 0.876 
 2000  2001  2002  2003  2004  2005  2006  2007  2008  <NA> 
0.888 0.895 0.907 0.921 0.930 0.945 0.959 0.975 0.994 1.000 

Which proportion of songs was created before the year 2000?

  • Wrong
  • Correct
  • Wrong
  • Wrong
Back to top