Practical 4 worksheet
Open your project for this week in RStudio. Then, open a new Markdown file with HTML output and save it in the r_docs
folder. (Give it a sensible name, like worksheet_04
or similar!)
For each of the tasks in Analyses, write your code to complete the task in a new code chunk.
Remember, you can add new code chunks by:
```
{r}
, press ↵ Enter, then ```
again.To prepare for the take-away paper, make sure you knit this document when you’ve finished the tasks.
Load the tidyverse
package and read in the data in the setup
code chunk.
This data is different from previous weeks! Make sure you use the correct URL below, otherwise you will not be able to complete the tasks properly.
If you are working on University computer, use the following code instead:
Review the Codebook at the link below, which has all the information you need about this dataset.
You will need the output from all of the following tasks in order to complete the worksheet quiz.
Using R, calculate the number of cases in the dataset before any cleaning and store it in a new object called n_initial
.
Using the Codebook, change the gender
variable into a factor and give its levels the right labels. Then, print out a table of the gender
variable.
Identify any rows in the dataset from participants that did not answer any of the rating scale questions, or that were too young to ethically participate in this study. Print out a tibble of these rows, then remove them from the dataset.
Using R, calculate the number of cases in the cleaned dataset and store it in a new object called n_final
.
Knit your worksheet once you’ve finished. You should see all of your code and output in the HTML document that it produces. This HTML will be saved in the same folder as the RMarkdown you knitted it from.
If you encounter a knitting error, bring it to the next practical!
Make sure you have the RMarkdown or knitted HTML on hand when you take the worksheet quiz - you will need your answers to the above tasks.
Good luck!