Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Lab Homework # 1

Instructions

In this assignment, you will use data from the Poli 210 Class Survey that is included in the assignment folder. The codebook for the class survey is also included in the assignment folder. You will need both les for this assignment. Download these les and save them to a folder that you will designate as your working directory for this assignment.

In a separate document, answer the questions below.  Note that only .doc, .docx, or .pdf les are accepted for the answers to your assignment. Do not submit your assignment using Macs pages app or another le format.  Submit your answers, along with your R script, to the Assignment 1 folder on MyCourses before Sunday, October 2 at 11:59pm. You must submit two les to get full marks:  (i) your answer sheet with the questions below and (ii) your R script.  Submit your R script as a separate le. Do not just copy and

paste your R code into your assignment answer sheet.

Assignment

1. If you have not already done so, install  R and RStudio on your computer or locate an on-campus computer with R and RStudio that you can use for your work. Review the posted Lab Guides as needed. Open RStudio and set your working directory.

2.  Notice that the Class Survey is saved as an Excel le ( .xlsx).  There are different packages you can use to work with data saved in this le format. One useful package is called readxl. Install the readxl package and load the package into R using the install.packages("") and library() functions.1

3.  Use the read_excel() function from the readxl package to read the Class Survey dataset into R. Store the dataset as an object.

4.  How many observations are in the dataset? How many variables are in the dataset?

5.  Review the codebook for the class survey and nd the variable that measures respondents’ political ideology on a left-right self-placement scale.  What is the name of this variable as it appears in the dataset? What is the level of measurement for this variable?

6.  Examine how this variable measuring political ideology is distributed in the class using both the table() and the hist() functions. If necessary, be sure to tell R to ignore any missing values before reporting your results. Save the histogram to your working directory and include the graph in your assignment answer sheet. Make sure your histogram has an appropriate title as well as informative labels for the x- and y-axes.

7.  Report the mean, median, mode, and standard deviation for this measure of respondents’ political ideology, removing missing data if necessary.

8.  Based on your answers to questions 6 and 7, how would you characterize the distribution of political ideology in the sample (2 to 4 sentences)? Be sure to make reference to the data in your answer.

9.  Create a new variable where self-reported political ideology is recoded into three categories:  “Left- leaning”, “Moderate”, and Right-leaning”. How do you define each of these categories, with respect to the original measure of political ideology? Justify your decision (1 to 2 sentences) and use table() to determine the number of individuals in each category on your newly recoded variable. Report the number of individuals in each of these categories in your answer sheet (a screenshot of the result is ne).

10. What is the level of measurement for this newly recoded measure of political ideology?