Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can anyone give me instructions on how to do this, i'm lost. Just telling me what the code I should be using should look like

can anyone give me instructions on how to do this, i'm lost. Just telling me what the code I should be using should look like would be helpful.

Do the following:

  1. Start a new project in RStudio Cloud.
  2. Install the package tidyverse.
  3. Upload the .rds version of the state-legislators data set from the data page. This data set contains ideology scores for legislators in the lower house of the 50 U.S. states similar to the NOMINATE scores for the U.S. House of Representatives that weve been using.
  4. Start a new R script. Save the script as analysis.R.
  5. In the script, do the following (include comments!):
    1. Load the tidyverse package.
    2. Load the data file state-legislators.rds.
    3. Use the glimpse functions to quickly (1) check the data are what you expect and (2) see the variable names.
    4. Create a density plot where the x aesthetic corresponds to ideology and the color aesthetic corresponds to party. Facet by state.
    5. Improve the plot using the labs() functions. Use a theme that you like.
  6. At the bottom of your script, in three separate comments, jot down three observations about the data. For example, Party 1 in State A is more conservative than Party 1 in State B. Feel free to briefly elaborate why those observations might be true. For example, perhaps because the voters in State A are more conservative than in State B. Hint: to break your comments into equally-sized lines, you can highly the comment and click Code > Reflow Comment.
  7. Once you are satisfied with your code and observations, click the tiny notebook icon (to the left of the Run button). When prompted, select PDF (PDF tends to work better, in my experience) or MS Word. You may be prompted to download the documentdo it! If not, then select the Files tab in the lower-right, check the box for the document you want to download (it should be analysis.docx or analysis.pdf), and click More > Export, and follow the instructions Submit this docx or .pdf file to Canvas. Do not submit the .R script itself.

Examples:

The follow shows the basic format of the R code and shows what the output should look like after you compile it into a notebook.

  • R script [R]
  • MS Word Output [docx]
  • PDF Output [pdf]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions