Question 1. There are errors in each of the following lines of code. Find and correct them!

my.vec <- 1 2 3 4 5
9group.mean <- 3

Question 2. Create a vector called multiples.of.five showing all the mulitiples of 5 from 0 to 100 (e.g.; 5, 10, 15, … 100)

Question 3. Create the vector 1, 2, 1, 2, 1, 2, 1, 2 vector using rep()

Question 4. Create the vector 1, 1, 1, 1, 2, 2, 2, 2 vector using rep()

Question 5. Create the following sequence of numbers [10, 20, 30, 40, 50, 12, 13, 14, 97, 107, 117, 127, 137] using a combination of the c(), a:b, and seq() functions.

Question 6. You’re running a new experiment and need to assign 100 people to 1 of 4 groups. You want to assign the first participant to group 1, the second participant to group 2 (etc.). Then, the fifth participant should be in group 1 and the sixth should be in group 2. Create a vector called ``group.assignment’’ with the appropriate numbers.

Question 7. The forecast for the upcoming voyage looks promising. The high temperatures for the next 5 days in Celsius 17, 21, 18, 21, 14. Unfortunately, your American shipmate has no idea what Celsius is. Convert these temperatures to Fahrenheit using basic math operations. Call this vector “Fahrenheit.” Hint: The formula to convert Celsius to Fahrenheit is y = x * 9/5 + 32, where x is the temperature in Celsius and y is the temperature in Fahrenheit.

Question 8. Oops, it turns out that the equipment that the weather service was using to measure the temperature was wrong - the temperature was actually .5 degrees colder than the original readings said. Create a new vector called Celsius.corrected showing the true values.

People at the mensa eat an unbelievable number of french fries. But do professors and students eat different amounts?? To test this, you randomly sampled 10 students and 10 professors and counted how many fries they had on their plates.

Group Number of Fries
Students 119, 124, 121, 79, 94, 106, 88, 128, 94, 80
Professors 131, 93, 103, 96, 101, 114, 125, 116, 116, 114

Question 9. Create two vectors called student.fries and professor.fries containing the data

Question 10. What was the mean number of fries eaten by students? What about by professors?

Question 11. What was the standard deviation of fries eaten by students? What about by professors?

Question 12. Create a vector called student.meandiff showing how different each student’s value was from the mean of all the students

Pirates are very proud of their beards, and every pirate captain wants his pirates to have the best beards in the lands. After some Poogling, you read a blog post which said that eating raw mean can increase the length of one’s beard. To test this, you told your crew of 10 pirates to switch from eating cooked meat to raw meat. Here are the lengths of your pirate’s beards before and having switching to raw meat.

Week Beard Lengths
Before raw meat 31, 21, 25, 28, 26, 37, 27, 31, 39, 37
After raw meat 32, 43, 40, 35, 48, 42, 38, 38, 41, 50

Question 13. What was the mean beard length of pirates before and after eating raw meat?

Question 14. Create a vector called beard.change showing the changes in beard length for each pirate.

Question 15. What was the maximum and minimum change in beard lengths?

The Zeigarnik effect states that people remember uncompleted tasks better than completed ones. If this is true, then students should forget a lot of course material when the course is over. To test this, you gave a surprise exam to a group of psychology students one week after the course was over. Here were their scores at the final exam, and at the surprise exam:

Exam Grades
Final 80, 93, 76, 88, 76, 98, 73, 80, 71, 82
Surprise 66, 87, 62, 79, 66, 96, 67, 73, 60, 78

Question 16. What was the mean and median grade of each exam?

Question 17. Create a vector called change showing the change in exam scores for each student.

Question 18. What was the median change in exam grades?

The Barrat Impulsiveness Scale (BIS) measures how impulsive a person is. The scale contains several items, such as “I plan tasks carefully” where each item is scored on a scale of 1 to 7, where a value of 7 means very impulsive, and a value of 1 means not at all impulsive. You administer 3 questions from the BIS to 5 students and collect the following data:

Question Responses
I don’t pay attention 1, 4, 1, 2, 7
I change hobbies 2, 7, 5, 2, 7
I buy things on impulse 1, 6, 3, 2, 7

Question 19. Create a vector called “BIS.scores” showing the average score for each of the 5 participants.