table.theme <- table(songs$THEME,
exclude = NULL)Proportion Table
We will now continue to work with the table that we made on the previous page.
As a first step, we can save the table as an object for further processing:
If we now use the command prop.table() on the object table.theme, we will see the proportions of the themes. This indicates how large the share of each theme is (with a number between 0 and 1).
prop.table(table.theme)
Heartbreak Life_and_death Love
0.145 0.131 0.139
Party_songs People_and_places Politics_and_protest
0.162 0.145 0.141
Sex <NA>
0.131 0.006
If we multiply the proportions by 100, we will get the percentages.
prop.table(table.theme)*100
Heartbreak Life_and_death Love
14.5 13.1 13.9
Party_songs People_and_places Politics_and_protest
16.2 14.5 14.1
Sex <NA>
13.1 0.6
What percentage of the total number of songs in the Guardian list are about ‘People_and_places’?
- Wrong
- Wrong
- Correct
- Wrong
Now, you can try to make these two tables yourself. First make a frequency table of the variable YEAR. Save it as an object and make a proportion table using the object.
Make a frequency table and a proportion table for the variable YEAR. Use again theexclude = NULL argument.
table.year <- table(songs$YEAR,
exclude = NULL)
table.year
1916 1922 1928 1929 1931 1932 1935 1936 1938 1939 1940 1941 1944 1946 1949 1950
1 1 6 2 2 2 1 1 2 3 1 2 2 2 1 2
1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966
3 1 1 4 3 9 3 6 10 5 14 7 17 27 33 37
1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982
33 39 31 23 30 27 24 27 23 18 27 25 34 25 19 18
1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998
25 22 18 17 18 15 19 10 10 14 11 18 12 7 8 7
1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 <NA>
11 12 7 12 14 9 15 14 16 19 6
prop.table(table.year)
1916 1922 1928 1929 1931 1932 1935 1936 1938 1939 1940 1941 1944
0.001 0.001 0.006 0.002 0.002 0.002 0.001 0.001 0.002 0.003 0.001 0.002 0.002
1946 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960
0.002 0.001 0.002 0.003 0.001 0.001 0.004 0.003 0.009 0.003 0.006 0.010 0.005
1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973
0.014 0.007 0.017 0.027 0.033 0.037 0.033 0.039 0.031 0.023 0.030 0.027 0.024
1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986
0.027 0.023 0.018 0.027 0.025 0.034 0.025 0.019 0.018 0.025 0.022 0.018 0.017
1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999
0.018 0.015 0.019 0.010 0.010 0.014 0.011 0.018 0.012 0.007 0.008 0.007 0.011
2000 2001 2002 2003 2004 2005 2006 2007 2008 <NA>
0.012 0.007 0.012 0.014 0.009 0.015 0.014 0.016 0.019 0.006
As you can see, the proportion table for the variable year is not very informative due to the large number of categories of the variable. Cumulative frequency tables can help with this problem. How to make them, you will learn on the next page.
Back to top