- Start with a blank sheet of paper. Think about your ten friends. Write down their names (given names, although pseudonyms will work too) in a column.
- For each of the friends, think about how long you’ve known them. It can be in months, years, or any other unit that can be meaningfully represented by a number. Write down the numbers next to the names.
- Think about a dirty secret that you have. If you have more than one, pick the dirtiest. If you don’t have any, pretend you do. I leave to you deciding what counts as dirty, but it may include things as diverse as affection for Steven Seagal, binge watching Lost, peeing in a public park, spitting in your spouse’s coffee, or deliberate destruction of your kid’s favourite toy, because he or she insisted you should tell him or her a bedtime story when you were trying to focus on another episode of Lost, and the like. The list is only illustrative and, of course, far from complete. In any case, you should get the idea: anything that is illegal, against social norms, or at least potentially shameful can be your dirty secret. Now, with the dirty secret in mind, will you trust your friends from the list with that secret? For each friend, write “yes” if you would and “no” otherwise.
- For each friend, think how often you meet with them to talk about private matters — whether online, on the phone, or in the real world (but online chats or email messages don’t count as meetings). Classify your estimates into the following categories: (a) at least once a day; (b) several times a week; (c) several times a month; (d) once a month or less.
- Write down the gender of each friend on your list.
- Open a new R script in R Studio. Using the function
setwd(), set up a working directory on your computer’s drive. Remember that after typing setwd("") in your script, you can place the cursor between the quotation marks and press the Tab button which will open a drop down list to help you navigate through folders and subfolders on your computer.
- Follow the example on page 48 of the presentation that I emailed you earlier, use the information on your ten friends to create a data frame. The resulting data frame will have ten rows (one for each friend) and five columns (representing the information on your friends’ names, how long you’ve known them, if you would trust them with your dirty secret, how often you talk with them, and their gender). Use the following names for your variables (columns):
person, how_long, trust, how_often, gender, respectively. Remember to assign some name to the data frame — using my_friends <- (or some other fancy name) — because you’ll use it in the next exercises!
- Using the subsetting methods we’ve discussed in class, select the rows of the data frame which correspond to friends
- of the same gender as you,
- whom you would trust with your dirty secret,
- whom you talk to once a week or more often,
- whom you’ve known for at least five years (or the equivalent in months, weeks, days, or any other unit you fancy),
- of your gender whom you can trust with your dirty secret,
- you’ve known for less than five years and can trust them with your dirty secret,
- you’ve known for at least five years and whom you talk to once a month or less
- of your gender whose name is not Zbigniew
- whose name is Kinga and whom you wouldn’t trust with your dirty secret
- who do not share your gender, whom you’ve known for at least three years, and who share name with your favourite literary (or TV, or film) character.
- Save your workspace in a file named
ha2_workspace_your_name.RData.
- Save your script in a file named
ha2_script_your_name.r.
- Email the script and the workspace to me by Monday, Nov 20.
- Should you have any questions concerning this homework or the course in general, do not hesitate to email me.