Name:
Go to https://voteview.com/data and download the member ideology data for the 118th House of Representatives. In the chunk below, set your working directory to wherever you have saved that data, and load the data into R.
dat <- read.csv('H118_members.csv')
Answer the following questions about the data:
Who was the most conservative member of the 118th House of Representatives? Greg Lopez
Who was the most liberal member of the 118th House of Representatives? Sylvia Garcia
Using the chunk below, make a density plot showing the distribution of the ideology variable, nominate_dim1.
plot(density(dat$nominate_dim1))
Using the chunk below, create a variable for the age of each member. This will not be exact, as you don’t have the exact birthdate for each member, but you should be able to get a rough age by using the members’ birth years. Using the variable you create, answer the following question:
table(dat$born)
##
## 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951
## 1 3 1 1 2 2 2 3 3 4 5 9 8 6 9 7
## 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967
## 8 13 10 12 10 9 14 10 12 13 17 12 15 12 15 8
## 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983
## 8 13 10 9 12 8 11 10 20 6 8 11 13 8 10 6
## 1984 1985 1986 1987 1988 1989 1997
## 9 3 6 2 7 4 1
median(dat$born)
## [1] 1965
Using the chunk below, make the following subsets of your data:
dat_subsettexas <- subset(dat,dat$state_abbrev=='TX')
dat_subsetrep <- subset(dat,dat$party_code=='200')
dat_subsetdem <- subset(dat,dat$party_code=='100')
dat_subsetpast1995 <- subset(dat,dat$born > 1965)
table(dat_subsetpast1995$party_code)
##
## 100 200
## 105 113
How many members represented districts in Texas in the 118th House of Representatives? 39
How many Republicans served in the 118th House of Representatives? 230
How many Democrats served in the 118th House of Representatives? 221
Of the members born after the median birth year, how many are Republicans and how many are Democrats? 105 Democrats 113 Republicans
Using the chunk below, create a scatter plot with member age on the x-axis and member ideology (nominate_dim1) on the y axis
Using the chunk below, create two different versions of the same scatter plot described above – one using the subset of only Democratic members that you created above, and the other using the subset of only Republican members.
The republican ideological shifts seem to become more progressive, leaning closer to the moderate ideological perspective as members become younger. On the same coin, democratic members seem to become more moderate as well as they get younger in age.