Chart Your Own Survey SOCL 3633 Research Methods · Lab 9 · Midwestern State University
Two weeks ago you launched a survey. Today you find out what your respondents said. You load your responses into R, chart a shared question and one of your own, and count how many people fall into each group. Keep this page open next to RStudio and work through the tabs in order. Before you leave, you submit two things in the Lab 9 submission on D2L: your response sheet and the picture file of your own chart.
Get set up
nrow(survey) prints the number of people who answered your survey. The practice file has 16.Two new tools today
If something goes wrong
| What you see | What to do |
|---|---|
| "my_survey.csv does not exist in current working directory" | The file is in a different folder, or its name is different. Check the Files pane. Then click Session, Set Working Directory, To Source File Location, and run Step 1 again. |
| The file is named my_survey.csv.csv, or it is a .zip file | Windows hides file endings, so typing ".csv" can add a second one. Rename it so the full name is my_survey.csv. If you have a .zip file, open it and take out the .csv file. |
A + sign in the Console | A parenthesis or quotation mark is missing. Press Escape in the Console, fix the line, and run it again. |
On your own: Step 5, your question 4
Column 5 holds your question 4, the first question you wrote. You chart it the same way you charted satisfaction, but you set the order of the answer choices yourself.
- Run the
names(survey)[5]line, thencount(survey, my_question). Look at the exact spelling of each answer choice. - In the
levels = c(____)blank, type each answer choice inside quotation marks, separated by commas, in the order you want from the bottom of the chart to the top. Copy the spelling from the count. Run the lines. - Run the chart lines. Look at the chart, then replace "Write your title here" with a complete sentence of about ten words that says what it shows, and write your own subtitle. Run the chart lines again.
- Write one
ggsave()line that savesmy_chartwith your last name, for examplesmith_lab9.png, and run it.
levels list is spelled differently from the data, so R could not match it. Compare the spelling with your count, fix it, and run Step 5 again from the mutate() line. If the NA bar was also in your count before you set the levels, it shows people who skipped the question. Keep it, and mention it in your answers.How many in each group? Step 6
Your survey asked everyone question 3: student, working full-time, working part-time, or other. Step 6 counts your question 4 answers within each of those groups.
- Put
statusin the blank and run the line. - Each row is one combination of a status and an answer, and
nis the number of people in it. Find the row with the smallestn.
Lab 9 response sheet
Answer in complete sentences. Then assemble your answers and paste them into the Lab 9 submission in D2L. In the same submission, upload the picture file of your own chart. Your answers stay on this page and are not sent anywhere until you paste them.
Sources
Wickham, Hadley, Jim Hester, and Jennifer Bryan. 2024. readr: Read Rectangular Text Data. R package. https://readr.tidyverse.org
Wickham, Hadley, Romain François, Lionel Henry, Kirill Müller, and Davis Vaughan. 2023. dplyr: A Grammar of Data Manipulation. R package. https://dplyr.tidyverse.org
The practice file example_survey_responses.csv contains invented responses written for this course. It does not describe real people.