Homework 1 Yaniv Brandvain 01/21/2016 1. Let ‘v1’equal a vector with the numbers four and two. Let ’v2’ equal a vector with the numbers five, twenty, and four. Let ‘v3’ be a vector with the numbers one through six [try using the colon operator, “:”, to do this]. a. what is the output of v1 + v2? b. what is the output of v1 + v3? c. what is the output of v2 + v3? d. Explain the differences in these answers in relation to error warnings, and unexpected behavior in R 2. Make a vector ‘v4’ of: eight, five, nine, one, negative three, zero, and twelve a. use indexing and the sum() function to add the second, fourth, and seventh entry in v4 b. combine indexing with the sum() function to add the second, fourth and seventh entry in v4 c. sample at random, two elements v4 [hint, use the sample() function] 3. Use R to generate a vector of all integers between 6 and 10 a. using the colon operator b. using the seq function 4. Use the rep function in R to generate a vector with all integers between 6 and 10 repeated four times a. Cycling through 6, 7, 8, 9 ,and 10 b. First repeating 6 four times, then repeating 7 four times, etc.. 1 5 Chapter 1. Question 14. ‘Identify whether the following variables are numerical or categorical. If numerical, state whether the variable is discrete or continuous. If categorical, state whether the categories have a natural order (ordinal) or not, (nominal)’. Answer with reference to the variable [i.e. The height of this building is a continuous, numerical variable]. a. Number of sexual partners in a year b. Petal area of rose flowers c. Heartbeats per minute of a Tour de France cyclist, averaged over the duration of the race d. Birth weight e. Stage of fruit ripeness (e.g. underripe, ripe, or overripe) f. Angle of flower orientation relative to the position of the sun g. Tree species h. Year of birth i. Gender 6. Chapter 1, Questions 23 and 24 23. During WWII the British Royal Air Force estimated the density of bullet holes on different sections of planes returning to base for aerial sorties. Their goal was to use this information to determine which plane sections most needed additional protective shields (It was not possible to reinforce the whole plane because it would weigh too much). They found that the density of holes was highest on the wings and lowest near the cockpit, where the pilot sits (their initial conclusion, that therefore wings should be reinforced was later shown to be mistaken). What is the main problem with this sample: bias or large sampling error? What part of the pale should have been reinforced?’ 24. In a study of diet preferences in leaf cutter ants, a researcher presented 20 randomly chosen ant colonies with leaves from the two most common tree species in the surrounding forest. The leaves were placed in piles of 100, one pile for each tree species, close to colony entrances. Leaves were cut so that each was small enough to be carried by a single ant. After 24 hours, the researcher returned and counted the number of leaves remaining of the original 100 of each species. Some of the results are shown in the following table 2 species # of leaves removed Spondis mombin Sapium thelocarpum total 1561 851 2412 Using these results the researcher estimated the proportion of Spondius leaves taken as 0.65 and concluded that the ants have a preference for leaves of this species. a. identify the two variables whose association is displayed in the table. Which is the explanatory variable and which is the response variable? Are they numeric or categorical? b. Why do the 2412 leaves used in the calculation of the proportion not represent a random sample? c. Would treating the 2412 leaves as a random sample most likely affect the accuracy or the precision of the estimate? d. If not the leaves, what units were randomly sampled in the study? 3
© Copyright 2026 Paperzz